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