Home > Software design >  Read a column from a table which its id is another table in mysql
Read a column from a table which its id is another table in mysql

Time:02-25

Probably I dont ask the title well.

I have three tables as shown in the figure.

I want to get the column x in table C where wid is in table B. Some of the wid in table C is not needed, I want only wids that their mid in table B are in table A.

Can you help me to solve this?

enter image description here

CodePudding user response:

Joining tables on primary key = other table's foreign key. There are inner/outer left and equi joins. Read on it.

select A.Mid, C.X
from A
left join B on B.Mid = A.Mid
join C on C.Wid = B.Wid
  • Related