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

就好了

原文地址:https://www.cnblogs.com/qds1401744017/p/14133204.html