mysql - 這條聯(lián)合sql語(yǔ)句哪里錯(cuò)了
問(wèn)題描述
((( 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
這條語(yǔ)句哪里錯(cuò)了,半天沒(méi)找到,錯(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
問(wèn)題解答
回答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:建議分步排查。
不知道誰(shuí)選的答案沒(méi)幫助?分步排查的意思是將大的SQL語(yǔ)句拆分為多個(gè)小SQL語(yǔ)句排查。估計(jì)是他沒(méi)有領(lǐng)悟到。
相關(guān)文章:
1. javascript - sublime快鍵鍵問(wèn)題2. javascript - immutable配合react提升性能?3. vue.js - Vue 如何像Angular.js watch 一樣監(jiān)聽(tīng)數(shù)據(jù)變化4. 配置Apache時(shí),添加對(duì)PHP的支持時(shí)語(yǔ)法錯(cuò)誤5. css - 寫頁(yè)面遇到個(gè)布局問(wèn)題,求大佬們幫解答,在線等,急!~6. javascript - nodejs關(guān)于進(jìn)程間發(fā)送句柄的一點(diǎn)疑問(wèn)7. javascript - 移動(dòng)端上不能實(shí)現(xiàn)拖拽布局嗎?8. phpstudy8.1支持win11系統(tǒng)嗎?9. 實(shí)現(xiàn)bing搜索工具urlAPI提交10. Apache 已經(jīng)把網(wǎng)站根目錄的改為allow from all了,但是服務(wù)器還是不能訪問(wèn)?

網(wǎng)公網(wǎng)安備