Reputation: 353
I have three tables. The third table has foreign keys to the first two. Please see the attached screenshot for reference.
I want to select rows from Medicines based on category_ID and in result of this query I also want to show Comp_Name and category_Name of the resulted rows.
[]
Upvotes: 0
Views: 44
Reputation: 1864
Below is query for you, you need to use INNER JOIN
select Comp_Name, Category_Name
from Medicines as m
inner join Categories as c on c.Category_ID = m.Category_ID
inner join Company as co on co.Comp_ID = m.Comp_ID
just add your WHERE clause...
where m.Category_ID = 'your category id'
Upvotes: 1