gpt4 book ai didi

sql - 从两个相同的表中选择并相交

转载 作者:可可西里 更新时间:2023-11-01 07:48:36 27 4
gpt4 key购买 nike

查询:

SELECT id_user 
FROM Rating
Where id_movie=2
INTERSECT
SELECT id_user
FROM Rating
Where id_movie=3

但我得到:

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 Where id_movie=3 LIMIT 0, 30' at line 1

有解决办法吗??

最佳答案

下面的查询会做..

SELECT id_user 
FROM Rating
Where id_movie=2 and id_user in
( SELECT id_user FROM Rating Where id_movie=3);

关于sql - 从两个相同的表中选择并相交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1878255/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com