Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create table table1
- (
- id int,
- date1 date,
- date2 date,
- status int
- );
- insert into table1 (id,date1,date2,status) values
- (123, '2018-07-01','2018-07-20',0),
- (124, '2018-07-07',null,0)
- select * from table1
- UPDATE table1
- SET
- date1 = IF(date2 is null,date1,date2),
- date2 = NULL, status = 1
- WHERE id IN (123,124,125)
- UPDATE table1
- SET
- date1 = IF(date2 is null,date1,date2),
- date2 = NULL, status = 1
- WHERE id IN (123,124,125)
- select * from table1
Add Comment
Please, Sign In to add comment