insert into table when value doesnt exist?
I am trying to insert all entries in table b into table A when
the status is <32 and
it isnt already in ta开发者_JAVA百科ble a.
The 2nd part is what is giving me trouble. I wrote a subquery and my gut says i did it wrong and i also notice it taking a very long time to execute
how do i write this rest of the query?
table a { int id, fId }
table b { int id, status; string data; }
insert into a(fId) select id from b where status<32 and ???
insert into a(fId)
select id
from b
where status<32
and id not in (select fId from a)
精彩评论