Results 1 to 2 of 2

Thread: Checking If A Value In A Column In One Table Appears In A Column In Another Table

  1. #1
    Join Date
    Dec 2002
    Posts
    6

    Checking If A Value In A Column In One Table Appears In A Column In Another Table

    I'm trying to query a database (oracle) which I've created via SQL.

    It relates to an ordering system which tracks from a quote to invoicing. Obviously not all quotes are turned into orders. This is what I'm trying to find, which quotes are not ordered.

    I have a Quote table with quoteID as the PK. I have another table Order which has a foreign key quoteID which references Quote.

    Can anyone tell me how I find the records in Quote which do not appear in Order.

    Thanks
    CUDOG

  2. #2
    Join Date
    Sep 2002
    Location
    Amsterdam
    Posts
    53
    Try the following:

    SELECT quoteID from quotes
    WHERE NOT EXISTS
    (SELECT quoteID from Orders
    Where orders.quoteid = quote.quoteID)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •