mysql union查询语法错误

juesequ 发布于 2016/10/25 10:54
阅读 237
收藏 0
SELECT * FROM `products` WHERE id IN(
  (SELECT `id` FROM `products`) UNION ALL (SELECT `id` FROM `products`)

) ;

提示下面的错误:

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 'UNION ALL (SELECT `id` FROM `products`) )' at line 3
加载中
1
AlanVision
AlanVision
 (SELECT `id` FROM `products`) UNION ALL (SELECT `id` FROM `products`)

改成

 SELECT `id` FROM `products` UNION ALL SELECT `id` FROM `products`
联合查询是没必要用括号括起来的
juesequ
juesequ
666666 ,你是对的 ,框架生成的sql自动加上括号了
0
红薯
红薯

这个 SQL 你写的? 瞎写! 

juesequ
juesequ
测试用的额 求红薯赐教。 目前需要多表union,并有分页功能,不分页的话把外面一层去掉是可以的,
返回顶部
顶部