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 > Database Server Software > MySQL > Captured missing from two table

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-05-11, 04:30
bh_hensem bh_hensem is offline
Registered User
 
Join Date: Jun 2009
Posts: 18
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
Reply With Quote
  #2 (permalink)  
Old 01-05-11, 06:15
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,535
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
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