Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

MySQL: How to update a field only if condition is true

MySQL:  update a Field only if condition is true.Update a field only if condition is true in query

Using IF Statement we can do this
For example :- If i want to update user level if user score is 500+
and if user join time in 24 hour

We can add multiple condtion in IF statement

UPDATE table SET level = IF(score > 500 AND  jointime (HOUR, jointime , ‘2018-06-27 16:27:54’) > 24 , USERNEWLEVEL , level) WHERE user_id = 5

The post MySQL: How to update a field only if condition is true appeared first on PHPCORELAB.



This post first appeared on Quick Reference For PHP, please read the originial post: here

Share the post

MySQL: How to update a field only if condition is true

×

Subscribe to Quick Reference For Php

Get updates delivered right to your inbox!

Thank you for your subscription

×