查询错误(1064):'INTERSECT附近的语法错误(SELECT friend_id FROM user_friend_list WHERE user_id ='20'和
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了查询错误(1064):'INTERSECT附近的语法错误(SELECT friend_id FROM user_friend_list WHERE user_id ='20'和相关的知识,希望对你有一定的参考价值。
(SELECT friend_id FROM user_friend_list WHERE user_id = '13' and
`friend_id` in(select user_id from user_friend_list where friend_id='13' and `is_delete` = 'No')
and is_delete = 'No')INTERSECT(SELECT friend_id FROM user_friend_list WHERE user_id = '20' and
friend_id in(select user_id from user_friend_list where friend_id='20' and is_delete = 'No')
and is_delete = 'No');
答案
mysql中没有INTERSECT运算符。尝试使用INNER JOIN代替:
SELECT friend_id FROM
(SELECT friend_id ...) T1
INNER JOIN
(SELECT friend_id ... ) T2
ON T1.friend_id = T2.friend_id;
另一答案
MySQL不支持INTERSECT运算符。但是,您可以模拟INTERSECT运算符。
这里有一个在MYSQL中模拟INTERSECT的操作指南:
http://www.mysqltutorial.org/mysql-intersect/
以上是关于查询错误(1064):'INTERSECT附近的语法错误(SELECT friend_id FROM user_friend_list WHERE user_id ='20'和的主要内容,如果未能解决你的问题,请参考以下文章
Translating SQLException with SQL state '42000', error code '1064'错误