Subject | Re: [ib-support] Re: Not in query |
---|---|
Author | Helen Borrie |
Post date | 2001-07-02T00:07:16Z |
At 06:56 PM 01-07-01 +0300, you wrote:
Have you tried this?
insert into table2 select * from table1 where (not (exists(select commonkey from table2 where commonkey = table1.commonkey)))
Cheers,
Helen
All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________
>Helen,No. There is no "EXISTS IN" predicate that I know of. If there were, I don't know how it could work. EXISTS returns true if a select returns one or more rows, otherwise false.
>
>Will this SQL statement replicate all records present in table1 but not in
>table2 ?
>INSERT into table2 SELECT * FROM table1 WHERE NOT EXISTS IN (SELECT * FROM
>table2)
Have you tried this?
insert into table2 select * from table1 where (not (exists(select commonkey from table2 where commonkey = table1.commonkey)))
>Is the following statement the best way to retrieve a value from a table andDid you try compiling a procedure containing the statement to check whether (a) the compiler lets you do it and (b) the :number variable gets the value if EXISTS() succeeds?
>make sure that the record selected exists, ie the variable contains a valid
>value?
>if ( not ( exists(SELECT number FROM table1 where (id=1) INTO :number ) ) )
>then exception norecord;
Cheers,
Helen
All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________