Home > database >  How do you write a mysql query statement
How do you write a mysql query statement

Time:10-06

Question: whether the query table containing the Id if not include return Id if contain won't return

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
  • Related