SQL子查詢報錯syntax error at end of input


SELECT dict_name FROM sys_dictionary WHERE dict_type = 'gateway' and dict_code = beg.gateway_type
這一條作為子查詢時出現syntax error at end of input錯誤

百度一下是因為參數為空導致的, beg.gateway_type這個是左連接的右表, 所以的確可能為空.
於是我加了一個判斷, 改為:
CASE WHEN gateway_type is not null THEN (SELECT dict_name FROM sys_dictionary WHERE dict_type = 'gateway' and dict_code = beg.gateway_type) ELSE null END as gateway_typename

就好了


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM