Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
rdsuperlike
Creator
Creator

where exists syntax with sql

I want to do


Table1:

Load

a_key,

b,

c;

SQL

select * from

......;

where not exists (a_key)

from tab2.qvd;





Or



Load

a_key,

b,

c;

SQL

select * from

......;


MINUS


Tab2.qvd



but looks like syntax is wrong.

Can someone help me here?



4 Replies
Anonymous
Not applicable

Hi,

Is this complete script?

sunny_talwar

Table1:

Load

a_key,

b,

c;

SQL

select * from

......;

where not exists (a_key)

from tab2.qvd;

Are you trying to load data from SQL where a_key is null? Is that the intention here???

marcus_sommer

You couldn't apply a exists() to a sql-statement because it's a qv function. Commonly used in such cases is Preceding Load. Another possibilities are to load the sql-table complete and apply then a second load with an exists() filter - see also: The exists issue - or using a join/keep to filter your table.

If your sql-load is quite large it could be useful to convert the exists-logic in a sql-function like SQL: IN Condition.

- Marcus

Not applicable

You should load Table2.qvd and after that the LOAD with exists previous to the SQL:

Table2:

LOAD

    a_key,

    *

FROM Table2.qvd(qvd);


SQL_Table:

LOAD

    a_key, b, c

where exists(a_key, a_key);

SQL SELECT * FROM Table;