|
-
Jul 13th, 2005, 03:22 AM
#1
Thread Starter
Addicted Member
SQL Help [RESOLVED]
I have the following SQL Query:
VB Code:
SELECT * FROM ALLTAGS INNER JOIN
Trend_Definitions ON ALLTAGS.Real_Tag_NAME = Trend_Definitions.REAL_TAG_NAME
This passes back all the records in ALLTAGS that exsist in Trend_Definitions.
How can i change this to return all the recordes from ALLTAGS that DO NOT exist in Trend Definitions?
Last edited by mik706; Jul 18th, 2005 at 04:47 AM.
Mik706
-
Jul 13th, 2005, 03:29 AM
#2
Re: SQL Help
Just a guess...
VB Code:
SELECT * FROM ALLTAGS NOT IN
(SELECT * FROM ALLTAGS INNER JOIN Trend_Definitions ON
ALLTAGS.Real_Tag_NAME = Trend_Definitions.REAL_TAG_NAME)
Last edited by dee-u; Jul 13th, 2005 at 03:36 AM.
-
Jul 13th, 2005, 03:31 AM
#3
New Member
Re: SQL Help
SELECT * FROM ALLTAGS
WHERE ALLTAGS.Real_Tag_Name NOT IN
(SELECT Trend_Definations.Real_Tag_NAME FROM Trend_Definitions)
-
Jul 13th, 2005, 03:31 AM
#4
Re: SQL Help
I think this is right. Kind of late, so I'm not going to test it.
VB Code:
SELECT * FROM ALLTAGS LEFT JOIN
Trend_Definitions ON ALLTAGS.Real_Tag_NAME <> Trend_Definitions.REAL_TAG_NAME
-
Jul 13th, 2005, 03:41 AM
#5
Thread Starter
Addicted Member
Re: SQL Help
Cheers guys
-
Jul 13th, 2005, 03:43 AM
#6
Re: SQL Help
You need to use a left join - this forces all records on the left to be included regardless of whether or not there is a corresponding table on the right:
Code:
SELECT * FROM ALLTAGS LEFT JOIN
Trend_Definitions ON ALLTAGS.Real_Tag_NAME = Trend_Definitions.REAL_TAG_NAME
WHERE Trend_Definitions.REAL_TAG_NAME IS NULL
-
Jul 13th, 2005, 03:53 AM
#7
Re: SQL Help
 Originally Posted by mik706
Cheers guys 
Which code worked?
-
Jul 13th, 2005, 03:59 AM
#8
Thread Starter
Addicted Member
Re: SQL Help
Maxperts and visualAds both worked.
I got "Incorrect syntax near the keywork 'NOT'" when i tried yours and
dgliennas just returns the first record from ALLTAGS against all the records in Trend_Definitions.
-
Jul 13th, 2005, 04:41 AM
#9
Re: SQL Help
Glad that one of them worked for you. We all learned something.
I learned to try to test before posting
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|