Reputation: 7065
Please check the image.
Here i have 2 table. One is post table and another is fevorite table. Both has primary key and post_id
is FOREIGN_KEY in fevorite table.
Now my needs are:
I need all of those things in single query. Thanks in advance.
Upvotes: 0
Views: 48
Reputation: 13237
Use sub query to get your result:
SELECT * FROM Post WHERE post_id IN (
SELECT post_id FROM fevorite WHERE fevorite_by = 2)
Or you can do it by JOIN
SELECT P.*
FROM Post P
JOIN fevorite F ON F.post_id = P.post_id
WHERE F.fevorite_by = 2
Upvotes: 1