UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Multiple column search for "in" statement    
 
   
buttons
post Jul 27 2006, 09:06 AM
Post #1

New Member
Posts: 11



I've been stuck on this SQL query for a while.

I have two copies of the same table. One is before some rows have been deleted the other is after. That would be simple enough but I have multiple key fields. I would like to have a command that would find the lines that are missing in the new copy.

Something like:

CODE
  select ID from TABLE_COPY2 where ID not in (select ID from TABLE_COPY1)


Except adapted for a two columns search:

CODE
select ID, ID2 from TABLE_COPY2 where (ID, ID2) not in (select ID, ID2 fril TABLE_COPY2)


This syntax does not work but it's that logic I would like to use.

Any ideas on how I could do this (with or without my preferred logic!)?

Thanks

B.
Go to the top of the page
 
+
niesz
post Jul 27 2006, 09:12 AM
Post #2

Utter A-fishin'-ado
Posts: 17,723
From: Cincinnati, Ohio, USA . . . ><((((°>



Have you tried using the Unmatched Query Wizard?
Go to the top of the page
 
+
buttons
post Jul 27 2006, 09:21 AM
Post #3

New Member
Posts: 11



No. Where can I find that?
Go to the top of the page
 
+
niesz
post Jul 27 2006, 09:22 AM
Post #4

Utter A-fishin'-ado
Posts: 17,723
From: Cincinnati, Ohio, USA . . . ><((((°>



Queries Tab: New


Edited by: niesz on Thu Jul 27 10:23:52 EDT 2006.
Go to the top of the page
 
+
buttons
post Jul 27 2006, 11:20 AM
Post #5

New Member
Posts: 11



This will only work for one field. The wizard wont let me chose more.

Any other ideas?
Go to the top of the page
 
+
niesz
post Jul 27 2006, 11:32 AM
Post #6

Utter A-fishin'-ado
Posts: 17,723
From: Cincinnati, Ohio, USA . . . ><((((°>



You could try something like:

SELECT Table1.ID, Table1.MyField1, Table1.MyField2
FROM Table1 LEFT JOIN Table2 ON (Table1.MyField2 = Table2.MyField2) AND (Table1.MyField1 = Table2.MyField1)
WHERE (((Table2.MyField1) Is Null) AND ((Table2.MyField2) Is Null));

This example uses 2 fields in common.
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 19th May 2013 - 02:45 PM