1. We have moved to a new forum! There may be a few things not working properly so please let us know if you find a bug. Remember to use the bbCode [ sql ] tag for SQL statements.

Does Not Exist?

Discussion in 'SQL - Questions and Answers' started by self-taught, Sep 28, 2006.

  1. self-taught New Member

    Dialect: Oracle
    Table cp has primary key cp.id. In Table su, su.pid is a foreign key pointing to cp.id. However, not every record in table cp necessarily has an entry in table su. That is what I am looking for-all records in cp that don't have an entry in table su. Can somebody help me with the sql for this requirement?
    Thanks
  2. Dimitar Guest

    SQL:

    SELECT * FROM cp where id not in (select pid from su)

Share This Page