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 > Data Access, Manipulation & Batch Languages > ASP > Quick SELECT question (comparing tables)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-10-03, 22:05
jonah9 jonah9 is offline
Registered User
 
Join Date: Jul 2003
Location: Japan/California
Posts: 68
Question Quick SELECT question (comparing tables)

Quick question:

how can i make this sql statement:

SELECT table1.field1, table1.field2 FROM table1 WHERE field1 DOES NOT EQUAL table2.field1

basically i want to only select records from table1 that do not exist in table2

any help will be greatly appreciated,
thanks in advance,

Jonah
Reply With Quote
  #2 (permalink)  
Old 12-10-03, 22:31
jonah9 jonah9 is offline
Registered User
 
Join Date: Jul 2003
Location: Japan/California
Posts: 68
Lightbulb Re: Quick SELECT question (comparing tables)

OK then,

ill answer this myself:

SELECT [table1].[field1] FROM table1 WHERE NOT EXISTS (SELECT * FROM table2 WHERE [table2].[field1] = [table1].[field1])

hope this helps
Reply With Quote
  #3 (permalink)  
Old 12-10-03, 22:53
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
you could also do....

SELECT [table1].[field1] FROM table1
WHERE Table1.field1 NOT IN (SELECT [table2].Field1 FROM table2)

hope this helps
Reply With Quote
  #4 (permalink)  
Old 12-10-03, 23:25
jonah9 jonah9 is offline
Registered User
 
Join Date: Jul 2003
Location: Japan/California
Posts: 68
Thumbs up

thanks rokslide,

that looks like a good option as well.

Jonah
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On