Moshe:

I believe you want to use a LEFT JOIN.  

SELECT field1, field2, field3
FROM first_table
LEFT JOIN second_table ON first_table.keyfield =
second_table.foreign_keyfield

HTH
Andy 

-----Original Message-----
From: Moshe Tapnack [mailto:[EMAIL PROTECTED] 
Sent: Friday, March 18, 2005 8:15 AM
To: [email protected]
Subject: [ASP] SQL question


Hi 
 
i have a table with 2 DBs. obviously one field links from the one to the ID
of the second.
 
I would like to run a query - which records from table 1  have an value in
that field, but the corresponding ID in table 2 doesnt exist. ( and then if
it doesnt exist... then reset that field to zero.).
 
i know how to do this with 2 queries.... but that isnt very efficient, and
it also would take ages, cos i have 2000 records to check.
 
is there a quicker way to do this?
 
Thanks in advance!
Moshe
 
 


[Non-text portions of this message have been removed]



---------------------------------------------------------------------    
 Home       : http://groups.yahoo.com/group/active-server-pages
---------------------------------------------------------------------
 Post       : [email protected]
 Subscribe  : [EMAIL PROTECTED]
 Unsubscribe: [EMAIL PROTECTED]
---------------------------------------------------------------------
Yahoo! Groups Links



 





---------------------------------------------------------------------    
 Home       : http://groups.yahoo.com/group/active-server-pages
---------------------------------------------------------------------
 Post       : [email protected]
 Subscribe  : [EMAIL PROTECTED]
 Unsubscribe: [EMAIL PROTECTED]
--------------------------------------------------------------------- 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/active-server-pages/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to