sql server支持变量所以一般使用方法如下:
DECLARE @Val varchar(50) select @Val = param_value where t_param where param_name = ‘log_type‘ if(@Val is null) begin select @Val = param_default_value where t_param_info where param_name = ‘log_type‘ end select @Val
mysql中执行语句时不支持定义变量及条件判断,所以想了个办法,也能达到相同目的
SELECT IFNULL( (select param_value from t_param where param_name = ‘log_type‘), (select param_default_value from t_param_info where param_name = ‘log_type‘) ) as param_value;