Perocat
Perocat

Reputation: 1521

mysql use IF after SET only if condition is true

I know this query is not correct, but how should I write it?

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

The IF should be like this:

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

Upvotes: 0

Views: 73

Answers (1)

juergen d
juergen d

Reputation: 204746

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

Upvotes: 3

Related Questions