mysql - 這條聯(lián)合sql語句哪里錯(cuò)了
問題描述
((( 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
這條語句哪里錯(cuò)了,半天沒找到,錯(cuò)誤提示
[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
問題解答
回答1:你括號(hào)加太多了,相當(dāng)于最外面那層是(...) 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回答2:
a.log_id
回答3:建議分步排查。
不知道誰選的答案沒幫助?分步排查的意思是將大的SQL語句拆分為多個(gè)小SQL語句排查。估計(jì)是他沒有領(lǐng)悟到。
相關(guān)文章:
1. html5 - 如何實(shí)現(xiàn)帶陰影的不規(guī)則容器?2. html5 - 只用CSS如何實(shí)現(xiàn)input框的寬度隨框里輸入的內(nèi)容長短自動(dòng)適應(yīng)?3. javascript - 三目運(yùn)算符的一些問題4. python - uwsgi+django的搭建問題5. css - 移動(dòng)端字體設(shè)置問題6. javascript - ueditor引入報(bào)錯(cuò)問題7. c++ - win7在不刪除管理員密碼的前提下(密碼不為空),如何設(shè)置開機(jī)不需要密碼?8. html5 - H5 video 問題9. javascript - 移動(dòng)端上不能實(shí)現(xiàn)拖拽布局嗎?10. javascript - 循環(huán)嵌套多個(gè)promise應(yīng)該如何實(shí)現(xiàn)?
