Reputation: 81
I have 2 tables
1) movie
|id(pk),name|
============
|256 sdsd|
|524 jmjm|
|122 dfdf|
|525 erer|
|952 tyyt|
|600 yunt|
2) favorites
|fid(pk),movie_id,uid |
=========================
|1 256 454668|
|2 524 545656|
|3 122 454668|
|4 525 454668|
|5 952 454668|
|6 256 545656|
|7 625 454668|
|8 600 454668|
1st tables id and 2nd tables movie_id
are same items...
My problem is.. first I want to get movie_id where uid = 454668
then using that movie_id
(s) I want to list name
where 'id' = 'movie_ids
(list we got from last query) from first table but order by second tables fid
...
How I can go???
I am not good at inner and joins
Upvotes: 3
Views: 3935
Reputation: 32602
You can use INNER JOIN
for that.
SELECT Name
FROM movie m JOIN favorites f
ON m.id = f.movie_id
WHERE f.uid = 454668
ORDER BY f.fid
Upvotes: 7