I have 2 tables
我有两个表
1) movie
1)电影
|id(pk),name|
============
|256 sdsd|
|524 jmjm|
|122 dfdf|
|525 erer|
|952 tyyt|
|600 yunt|
2) favorites
2)收藏
|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...
第一表id和第二表movie_id都是相同的项目……
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
...
我的问题是…首先,我想要获取movie_id,其中uid = 454668然后使用movie_id(s)我想要列出第一个表中“id”=“movie_ids”(上一个查询中得到的列表)的名称,但是第二个表是fid…
How I can go???
我怎么可以? ? ?
I am not good at inner and joins
我不擅长内线和接球
1 个解决方案
#1
7
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
看到这个SQLFiddle
#1
7
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
看到这个SQLFiddle