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;

 

相关文章:

  • 2022-12-23
  • 2021-12-18
  • 2021-07-09
  • 2021-10-08
  • 2022-02-12
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-18
  • 2021-10-16
  • 2022-02-24
相关资源
相似解决方案