Sunday, February 26, 2012

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.

ThanksYou 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 (http://www.dummies.com/WileyCDA/DummiesTitle/productCd-0764540750.html) will probably do the job.

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

Adam

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 (http://www.dummies.com/WileyCDA/DummiesTitle/productCd-0764540750.html) will probably do the job.

-PatP

No comments:

Post a Comment