yurividal
yurividal

Reputation: 177

SQL 2 Joins in one Query

I am having trouble understanding this SQL. I have these 3 tables (see the image below). I need to find a way to extract the name and the maritial status of the person. I know i need 2 Joins, but i cant get it to work.

Desired Output:

John   Married
Mary   Widow

Tables:

person_per

per_ID   per_FirstName
   1     John
   2     Mary

person_custom

per_ID   status_code
   1         2
   2         4

list_lst

status_code   ???  
     1        Married
     2        Single
     3        Divorced
     4        Widow

Upvotes: 1

Views: 926

Answers (1)

Joel Coehoorn
Joel Coehoorn

Reputation: 416131

select per_FirstName, l.[status] /* you didn't put a name for that column */
from person_per p
inner join person_custom c on c.per_ID = p.per_ID
inner join list_lst l on l.status_code = c.status_code

Upvotes: 3

Related Questions