On 8-12-2014 20:50, Venkat Murty wrote:
How do I update multiple rows in a single sql statement.

Two tables:
create table some_table(id,  a, b, c);
create table temp_table (id, operation, a, b, c);

Operation:
Updating id, operation fields in temp_table if the record exists in some_table.


with ds as (select id, a , b, c  from some_table where c = 42)
update temp_table set id = ds.id, operation = 'UPDATE'
WHERE ds.a = temp_table.a  AND ds.b = temp_table.b;


I get the error " no such column: ds.id"


i hope this does it:

update temp_table
set id=(select id from some_table where c=42),
operation='UPDATE'
where exists (select 1
        from some_table s, temp_table t
        where s.a=t.a and s.b=t.b);




_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to