Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

SQL how to select a colomn from a forgein key without join

I hope you guys can help me.

I have 2 tables 1 called Stuk and one is called Niveau.

in the table Stuk I have a FK from the tabel Niveau. This is the column niveaucode the skill codes I have are:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

A EXAMPLE 1
B EXAMPLE 2
C EXAMPLE 3

If I select a musicpiece I dont want to see A, B or C I want to see EXAMPLE 1, EXAMPLE 2 or EXAMPLE 3. I have to do this without a JOIN

enter code here

>Solution :

SELECT S.[stuknr], S.[genrenaam],
CASE
  WHEN S.niveaucode='A' THEN 'EXAMPLE 1' 
  WHEN S.niveaucode='B' THEN 'EXAMPLE 2'
  WHEN S.niveaucode='C' THEN 'EXAMPLE 3'
  ELSE 'HMM'
END AS FLAG
FROM dbo.Stuk S 
WHERE  S.[jaartal] > 1995
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading