SELECT IF(@maxins < @num_of_ins, @maxins, @num_of_ins)
FROM( SELECT @maxins :=4, @num_of_ins:=10) f1
Ans: 4 [True]
But 10 [False]
答案 0 :(得分:2)
这是第一次发生..所以尝试在选择之前分配var值
set @maxins =4;
set @num_of_ins=10;
SELECT IF(@maxins < @num_of_ins, @maxins, @num_of_ins)