Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2009
    Posts
    18

    Unanswered: Captured missing from two table

    Hi..

    I have two table.. as example:-

    [code]
    TableA
    Date Time Number Charge
    5/1/2010 01:00 123456719 10.00
    5/1/2010 01:00 123456729 10.10
    5/1/2010 01:00 123456739 20.20
    5/1/2010 01:00 123456749 40.00
    5/1/2010 01:00 123456759 100.00

    TableB
    Date Time Number Charge
    5/1/2010 01:00 123456719 10.00
    5/1/2010 01:00 123456749 40.00
    5/1/2010 01:00 123456759 100.00
    5/1/2010 01:00 123456769 10.10
    5/1/2010 01:00 123456779 20.20
    [code]

    Based on the sample data.. What is the query could i display any data exist on TableA but not exist on TableB or any data exist on TableB but not exist on TableC.

    I have tried used outer join but its was display both data missing and not missing records.

    Please help me..

    Thank you,
    Baharin

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by bh_hensem View Post
    Based on the sample data.. What is the query could i display any data exist on TableA but not exist on TableB
    based on the sample data...
    Code:
    SELECT TableA.Date 
         , TableA.Time 
         , TableA.Number
         , TableA.Charge
      FROM TableA
    LEFT OUTER
      JOIN TableB
        ON TableB.Date   = TableA.Date         
       AND TableB.Time   = TableA.Time  
       AND TableB.Number = TableA.Number
       AND TableB.Charge = TableA.Charge
     WHERE TableB.Date IS NULL
    Quote Originally Posted by bh_hensem View Post
    or any data exist on TableB but not exist on TableC.
    there is no TableC
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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