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

Read a column from a table which its id is another table in mysql

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.

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

Can you help me to solve this?

enter image description here

>Solution :

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
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