sql - How to update records whose value is not in the ranges stored in another table -


i need update records in table it's value not part of range stored in table. query updates records it's value is part of range no problem:

update table_a join table_range on (table_a.x >= table_range.fromvalue , table_a.x <= table_range.tovalue) set table_a.somecolumn = 'is in range'

but can't figure out how update records of following query result:

select * table_a x not in ( select x table_a inner join table_range on (x >= fromvalue , x <= tovalue) )

thanks in advance

how following?

 drop table table_a;  drop table table_ranges;   create table table_a(     x    int        not null    ,flag varchar(20)  );   create table table_ranges(     fromvalue int not null     ,tovalue  int not null  );   insert table_a(x) values(10);  insert table_a(x) values(20);  insert table_a(x) values(30);   insert table_ranges values(0,9);  insert table_ranges values(10,19);  insert table_ranges values(20,29);    update table_a     set flag = 'not in range'   not exists(      select *        table_ranges r       a.x between r.fromvalue , r.tovalue   ); 

Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -