CodePudding user response:
This effect?set @ id=2000;
Select count (*) into @ con from t1 where id=@ id;
Select the if (@ con>=0, @ id, 0);
If it is stored procedures can be used if the exists of judgment
CodePudding user response:
# 10 id for this value
Select case when id is null then 10 else 'end from t where id=10