Re: [GENERAL] null and =
От | Lincoln Yeoh |
---|---|
Тема | Re: [GENERAL] null and = |
Дата | |
Msg-id | 3.0.5.32.19991206104518.008a8420@pop.mecomb.po.my обсуждение исходный текст |
Ответ на | Re: [GENERAL] null and = (Mike Mascari <mascarm@mascari.com>) |
Ответы |
timezone correction.
|
Список | pgsql-general |
At 04:59 PM 05-12-1999 -0500, Mike Mascari wrote: >Instead, I would use a correlated subquery with an EXISTS/NOT EXISTS test >against the criteria for which you are searching: > >SELECT t1.a, t1.b FROM dummy t1 >WHERE EXISTS (SELECT t2.a FROM dummy t2 WHERE t1.a = t2.a) >.... > I've got two tables, the first table contains "user accounts" and I'd like to insert rows in the second table if necessary (if the userids don't exist in the second table). My query to find out which ids need to be inserted is something like this: select usr_id,usr_login from users where usr_id not in (select userid from wm_accounts); (first table = users, second table = wm_accounts) Is there a way of doing this efficiently and effectively? I cannot use rules because I need to insert some extra nondatabase data into the second table. I would prefer a query which can work if the second table is null. The problem with other queries I thought of was they would return null if the second table is null. I could in theory modify the program which inserts rows to the first table and make it insert rows to the second table, however I'd like to keep a functional and logical separation between the two programs (they aren't supposed to be doing each others jobs). Any suggestions? Thanks, Link.
В списке pgsql-general по дате отправления: