mysql - 這條聯(lián)合sql語(yǔ)句哪里錯(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
這條語(yǔ)句哪里錯(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:建議分步排查。
不知道誰(shuí)選的答案沒幫助?分步排查的意思是將大的SQL語(yǔ)句拆分為多個(gè)小SQL語(yǔ)句排查。估計(jì)是他沒有領(lǐng)悟到。
相關(guān)文章:
1. javascript - axios請(qǐng)求回來的數(shù)據(jù)組件無(wú)法進(jìn)行綁定渲染2. css - 請(qǐng)問B站頂部的模糊半透明導(dǎo)航條是怎么實(shí)現(xiàn)的呢?3. 推薦好用mysql管理工具?for mac和pc4. pdo - mysql 簡(jiǎn)單注入疑問5. 雙擊安裝程序,安裝不了6. form表單中的label標(biāo)簽7. python - 如何用pandas處理分鐘數(shù)據(jù)變成小時(shí)線?8. javascript - dropload+tab頁(yè)面,圖文頁(yè)滾動(dòng)有兩個(gè)滾動(dòng)區(qū)域怎么破?9. Python中使用超長(zhǎng)的List導(dǎo)致內(nèi)存占用過大10. 為什么學(xué)習(xí)PHP
