如果条件为真,mysql在SET之后使用IF

时间:2013-06-20 17:51:46

标签: mysql sql

我知道这个查询不正确,但我应该怎么写呢?

UPDATE OFFER SET
IF(St != 3, St = 2 AND View = '$userupdate' AND Date_V_E = '$date', '')
WHERE Id = '$entryID'

IF应该是这样的:

if(St != 3){
   St = 2;
   View = '$userupdate';
   Date_V_E = '$date';
}else{
   //DO NOTHING
}

1 个答案:

答案 0 :(得分:3)

UPDATE OFFER 
SET St = 2, 
    View = '$userupdate', 
    Date_V_E = '$date'
WHERE Id = '$entryID'
and St <> 3