drop table if exists t1; create table t1 (a int, b int, primary key (a)); insert into t1(a,b) values(1,1),(2,1),(3,1),(4,1); update t1 set b=2 where a>0; select * from t1; a b 1 2 2 2 3 2 4 2 update t1 set b=3 where a<5; select * from t1; a b 1 3 2 3 3 3 4 3 update t1 set b=4 where a>1; update t1 set b=5 where a<4; select * from t1; a b 1 5 2 5 3 5 4 4 update t1 set b=6 where a>=1; select * from t1; a b 1 6 2 6 3 6 4 6 update t1 set b=7 where a<=5; select * from t1; a b 1 7 2 7 3 7 4 7 update t1 set b=8 where a>0 and a<2; update t1 set b=9 where a>=2 and a<3; update t1 set b=10 where a>=3 and a<=4; select * from t1; a b 1 8 2 9 3 10 4 10 update t1 set b=11 where a=1 or a=2 or a=3 or a=4; select * from t1; a b 1 11 2 11 3 11 4 11 replace into t1(a,b) values(1,1),(2,2),(3,3),(4,4); update t1 set b=b+1 where b>0; select * from t1; a b 1 2 2 3 3 4 4 5 update t1 set b=b-1 where b<6; select * from t1; a b 1 1 2 2 3 3 4 4 update t1 set b=5 where b>1; update t1 set b=6 where b<5; select * from t1; a b 1 6 2 5 3 5 4 5 update t1 set b=7 where b>=1; select * from t1; a b 1 7 2 7 3 7 4 7 update t1 set b=8 where b<=7; select * from t1; a b 1 8 2 8 3 8 4 8 replace into t1(a,b) values(1,1),(2,2),(3,3),(4,4); update t1 set b=10 where b>0 and b<2; update t1 set b=11 where b>=2 and b<3; update t1 set b=12 where b>=3 and b<=4; select * from t1; a b 1 10 2 11 3 12 4 12 replace into t1(a,b) values(1,1),(2,2),(3,3),(4,4); update t1 set b=11 where b=1 or b=2 or b=3 or b=4; select * from t1; a b 1 11 2 11 3 11 4 11 drop table if exists t1; create table t1(a int, b int, c int, primary key(a)); replace into t1(a,b) values(1,1),(2,2),(3,1),(4,2); update t1 set c=1 where a>0 and b>1; update t1 set c=2 where a<5 and b<2; select * from t1; a b c 1 1 2 2 2 1 3 1 2 4 2 1 update t1 set c=3 where a>=0 and b<=1; update t1 set c=4 where a<=5 and b>=2; select * from t1; a b c 1 1 3 2 2 4 3 1 3 4 2 4 update t1 set c=5 where a=0 or a=1 or a=2 or b=1; update t1 set c=6 where b=2 or a=1 or a=2; select * from t1; a b c 1 1 6 2 2 6 3 1 5 4 2 6 replace into t1(a,b,c) values(1,1,NULL),(2,2,NULL),(3,3,NULL),(4,4,NULL); update t1 set c=1 where a<=1 or b>=4; update t1 set c=2 where a>1 or b<4; select * from t1; a b c 1 1 2 2 2 2 3 3 2 4 4 2 drop table if exists t1; create table t1(a int, b int, c int, d int, primary key(a,b)); insert into t1(a,b,c,d) values(1,1,1,1),(2,2,1,1),(3,3,1,1); update t1 set c=c+1, d=d+1 where (a,b) > (0,0); select * from t1; a b c d 1 1 2 2 2 2 2 2 3 3 2 2 update t1 set c=c+1, d=d+1 where (a,b) < (4,4); select * from t1; a b c d 1 1 3 3 2 2 3 3 3 3 3 3 update t1 set c=c+1, d=d+1 where (a,b) >= (1,1); select * from t1; a b c d 1 1 4 4 2 2 4 4 3 3 4 4 update t1 set c=c+1, d=d+1 where (a,b) <= (1,1); select * from t1; a b c d 1 1 5 5 2 2 4 4 3 3 4 4 update t1 set c=c+1, d=d+1 where (a,b) in ((NULL,NULL),(0,0),(1,1),(2,2),(3,3),(4,4)); select * from t1; a b c d 1 1 6 6 2 2 5 5 3 3 5 5 update t1 set c=c+1, d=d+1 where (a,b)=(1,1) or (a,b)=(2,2) or (a,b)=(3,3); select * from t1; a b c d 1 1 7 7 2 2 6 6 3 3 6 6 update t1 set c=1, d=1 where (a,b) in ((1,1),(2,2),(3,3)); update t1 set c=c+1, d=d+1 where (a,b,c,d) >= (1,1,1,1); select * from t1; a b c d 1 1 2 2 2 2 2 2 3 3 2 2 update t1 set c=c+1, d=d+1 where (a,b,c,d) <= (3,3,3,3); select * from t1; a b c d 1 1 3 3 2 2 3 3 3 3 3 3 update t1 set c=c+1, d=d+1 where (a,b,c,d)=(1,1,1,1) or (a,b,c,d)=(2,2,1,1) or (a,b,c,d)=(3,3,3,3); select * from t1; a b c d 1 1 3 3 2 2 3 3 3 3 4 4 drop table if exists t1; create table t1(a int, b int, c int, d int, primary key(a,b)); insert into t1(a,b,c,d) values(1,1,1,1),(1,2,1,1),(1,3,1,1); update t1 set c=c+1, d=d+1 where a = 1; select * from t1; a b c d 1 1 2 2 1 2 2 2 1 3 2 2 update t1 set c=c+1, d=d+1 where a > 0; update t1 set c=c+1, d=d+1 where a >=1 ; select * from t1; a b c d 1 1 4 4 1 2 4 4 1 3 4 4 update t1 set c=c+1, d=d+1 where a < 4; select * from t1; a b c d 1 1 5 5 1 2 5 5 1 3 5 5 update t1 set c=c+1, d=d+1 where a <= 1; select * from t1; a b c d 1 1 6 6 1 2 6 6 1 3 6 6 update t1 set c=c+1, d=d+1 where a=1 or a=2 or a=3; select * from t1; a b c d 1 1 7 7 1 2 7 7 1 3 7 7 update t1 set c=c+1, d=d+1 where (a=1 or a=2 or a=3) and (b=1 or b=2); select * from t1; a b c d 1 1 8 8 1 2 8 8 1 3 7 7 update t1 set c=c+1, d=d+1 where a>=1 and b>=2; select * from t1; a b c d 1 1 8 8 1 2 9 9 1 3 8 8 drop table if exists t1; create table t1(a int, b int, c int, d int, primary key(a,b)); replace into t1(a,b,c,d) values(1,1,1,1),(2,2,2,1),(3,3,3,1); update t1 set d=d+1 where (a,b)>=(1,1) and c=1; select * from t1; a b c d 1 1 1 2 2 2 2 1 3 3 3 1 update t1 set d=d+1 where (a,b)>=(1,1) and c=3; select * from t1; a b c d 1 1 1 2 2 2 2 1 3 3 3 2 update t1 set d=d+1 where (a=1 or a=2 or a=3) and c>=1; select * from t1; a b c d 1 1 1 3 2 2 2 2 3 3 3 3 update t1 set d=d+1 where (a=1 or a=2 or a=3) and c<1; select * from t1; a b c d 1 1 1 3 2 2 2 2 3 3 3 3 update t1 set d=d+1 where (a=1 or a=2 or a=3) and (b=2 or b=3); select * from t1; a b c d 1 1 1 3 2 2 2 3 3 3 3 4 update t1 set d=d+1 where (a=1 or a=2 or a=3) and (b=2 or b=3) and c=3; select * from t1; a b c d 1 1 1 3 2 2 2 3 3 3 3 5 update t1 set c=c+1, d=d+1 where a>=0 and a<=3 and b>1 and b<3; select * from t1; a b c d 1 1 1 3 2 2 3 4 3 3 3 5 update t1 set c=c+1, d=d+1 where (c,d)>=(1,1); select * from t1; a b c d 1 1 2 4 2 2 4 5 3 3 4 6 update t1 set c=c+1, d=d+1 where (b,a) > (1,1); select * from t1; a b c d 1 1 2 4 2 2 5 6 3 3 5 7 drop table if exists t1, t2, t3; create table t1(a int, b int, c int, d int, primary key(a,b,c)); insert into t1(a,b,c) values (1,1,1),(2,2,2),(3,3,3); update t1 set d=1 where (a,b,c)>(0,0,0) and (a,b,c)<=(3,3,3); select * from t1; a b c d 1 1 1 1 2 2 2 1 3 3 3 1 create table t2(a varchar(1024), b varchar(1024), c varchar(1024), d varchar(1024), primary key(a,b,c)); insert into t2(a,b,c) values ('a','a','a'),('b','b','b'),('c','c','c'); update t2 set d='a' where (a,b,c)>=('a','a','b') and (a,b,c)<('b','b','c'); select * from t2; a b c d a a a NULL b b b a c c c NULL create table t3(a int, b varchar(1024), c timestamp(6) default "2012-01-01 12:00:00", d int, primary key(a,b,c)); insert into t3(a,b,c) values (1,'a','2014-02-17'),(2,'b','2014-02-17'),(3,'c','2014-02-18'); update t3 set d=1 where (a,b,c)>=(1,'a','2014-02-17 00:00:00') and (a,b,c)<=(2,'b','2014-02-18'); select * from t3; a b c d 1 a 2014-02-17 00:00:00.000000 1 2 b 2014-02-17 00:00:00.000000 1 3 c 2014-02-18 00:00:00.000000 NULL drop table if exists t1, t2, t3;