Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > Sybase > sql of using exist on multi column

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-08-04, 12:53
pengpeng pengpeng is offline
Registered User
 
Join Date: Jan 2004
Location: toronto
Posts: 1
sql of using exist on multi column

I have two tables,

create table t1(
col11 int,
col12 int,
col13 int)

and

create table t2(
col21 int,
col22 int)

I tried to write a sql statement as follow to get what exist in t1 but not in t2 and vice versa.

>select * from t1
where (col11, col12) not exists (select col21, col22 from t2)

I got the error:
Incorrect syntax near ','.

Then I had to using,
>select *
from t1
where t1.col11 not in ( select t2.col21
from t2
where t1.col11=t2.col21
and t1.col12=t2.col22)
and t1.col12 not in ( select t2.col21
from t2
where t1.col11=t2.col21
and t1.col12=t2.col22)

It works. But it takes a long time to finishe. Is there a way to use exist on multiple columns in where clause, or an other way to write my sql to improve performance?

Thanks.
Pengpeng
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On