mysql - 这条联合sql语句哪里错了
本文介绍了mysql - 这条联合sql语句哪里错了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
((( SELECT a.log_id,`create_date`,`content`,`creator`,`belong_to_user`,a.customer_code,`follow_up_way`
FROM gs_log a left join gs_customer b on a.customer_code = b.customer_code WHERE
( b.customer_code != '' AND b.customer_id = 2212 ) )) union (( SELECT a.log_id,`create_date`,`content`,`creator`,`belong_to_user`,`customer_code`,`follow_up_way`
FROM gs_log a left join gs_r_customer_log on a.log_id = gs_r_customer_log.log_id WHERE ( gs_r_customer_log.customer_id= 2212 ) ))) limit 0,10
这条语句哪里错了,半天没找到,错误提示
[SQL]((( SELECT a.log_id,`create_date`,`content`,`creator`,`belong_to_user`,a.customer_code,`follow_up_way`
FROM gs_log a left join gs_customer b on a.customer_code = b.customer_code WHERE
( b.customer_code != '' AND b.customer_id = 2212 ) )) union (( SELECT a.log_id,`create_date`,`content`,`creator`,`belong_to_user`,`customer_code`,`follow_up_way`
FROM gs_log a left join gs_r_customer_log on a.log_id = gs_r_customer_log.log_id WHERE ( gs_r_customer_log.customer_id= 2212 ) ))) limit 0,10
[Err] 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 'union (( SELECT a.log_id,`create_date`,`content`,`creator`,`belong_to_user`,`cus' at line 3
解决方案
你括号加太多了,相当于最外面那层是(...) limit 0,10,只能是(...) union (...) limit 0,10
(( SELECT a.log_id,`create_date`,`content`,`creator`,`belong_to_user`,a.customer_code,`follow_up_way`
FROM gs_log a left join gs_customer b on a.customer_code = b.customer_code WHERE
( b.customer_code != '' AND b.customer_id = 2212 ) ))
union
(( SELECT a.log_id,`create_date`,`content`,`creator`,`belong_to_user`,`customer_code`,`follow_up_way`
FROM gs_log a left join gs_r_customer_log on a.log_id = gs_r_customer_log.log_id WHERE ( gs_r_customer_log.customer_id= 2212 ) ))
limit 0,10
这篇关于mysql - 这条联合sql语句哪里错了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文