If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > exists: the absence of data

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-16-04, 19:32
adamgotch adamgotch is offline
Registered User
 
Join Date: Apr 2004
Posts: 5
exists: the absence of data

Can someone please tell me how to check if a record does not exist (as a secondary key) in one table when it exists in another as a primary key. The actual value of the record is not known ahead of time. I am dealing in sybase t-sql if that makes a difference. Also, can anyone recommend a good tutorial on t-sql.

Thanks
Reply With Quote
  #2 (permalink)  
Old 04-17-04, 12:36
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
You can use the NOT EXISTS condition in your WHERE clause to find rows in the parent table that have no related rows in the child table.

There are lots of good books on Transact-SQL, as well as SQL in general. If all you need is a good introduction, the SQL for Dummies will probably do the job.

-PatP
Reply With Quote
  #3 (permalink)  
Old 04-19-04, 10:16
adamgotch adamgotch is offline
Registered User
 
Join Date: Apr 2004
Posts: 5
Thanks

Thanks Pat. Works exactly how I wanted it. Thanks for the book rec. too.

Adam

Quote:
Originally posted by Pat Phelan
You can use the NOT EXISTS condition in your WHERE clause to find rows in the parent table that have no related rows in the child table.

There are lots of good books on Transact-SQL, as well as SQL in general. If all you need is a good introduction, the SQL for Dummies will probably do the job.

-PatP
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

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