从两个相同的表中选择相交
查询:
SELECT id_user
FROM Rating
Where id_movie=2
INTERSECT
SELECT id_user
FROM Rating
Where id_movie=3
但我得到:
1064 - 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在第 1 行的 'INTERSECT SELECT
id_user
FROM RatingWhereid_movie
=3 LIMIT 0, 30' 附近使用的正确语法< /p>
语法有解决办法吗??
The query:
SELECT id_user
FROM Rating
Where id_movie=2
INTERSECT
SELECT id_user
FROM Rating
Where id_movie=3
but I get:
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTERSECT SELECT
id_user
FROM Rating Whereid_movie
=3 LIMIT 0, 30' at line 1
any have solution??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
以下查询将执行..
Following query will do ..
MySql 中没有 Intersect、Minus 关键字,解决方法分别是
请查看这里
在 MySQL 中执行 INTERSECT 和 MINUS
我已经尝试过(虽然我是 SQL Server 人员)
输入:
使用相交(如果在 SQL Server 中运行)的输出将是
使用
Inner 的MySQL 兼容查询
查询 1 使用
交叉连接
连接 查询2
使用子查询的查询3
上面已经回答了。
Intersect, Minus keywords are absent in MySql and the workarounds are
Please look into here
Doing INTERSECT and MINUS in MySQL
I have given a shot (though I am a SQL Server guy)
Input:
The output by using an intersect (if run in SQL Server) will be
MySQL compatible queries
Query 1 using
Inner join
Query 2 using
Cross join
Query 3 using subquery
Already answered above.
怎么样:
这里的想法是,您希望将“Rating”中的一行与“Rating”中的另一行连接起来,同一用户已看过电影 2 和 3。
How about:
The idea here is that you want to join a row in Rating with another row in Rating, for which the same user has seen movies 2 and 3.