jonezy (jo****@donotmailmejonezy.com) writes:
i didnt think my sql qeury was that complicated that it would crash my
web app. all im trying to do is filter data between two tables. heres
my query
<cfquery name="GetResults" datasource="#datasource#">
SELECT *
FROM Content, Content_Sites
WHERE Content.ContentID <> Content_Sites.ContentID
ORDER BY Content.ContentID DESC
</cfquery>
equals works, but when i try not equals, it all goes haywire. any ideas?
Yes and no. Since I don't know your tables, and neither know what you
are trying to achieve, how could I really have any ideas?
But, OK, having seen people using <> in the wrong place before, I can
make a guess. Say that both table have a thousand rows. You are now
asking for all million combinations of these two thousand rows - save
those that have the same ID.
I guess what you are looking for is really something like:
SELECT *
FROM Content c ,
WHERE NOT EXISTS (SELECT *
FROM Content_Sites cs
WHERE c.ContentID = cs.ContentID)
ORDER BY c.ContentID DESC
That is, list all Content that does not have any content site.
--
Erland Sommarskog, SQL Server MVP,
so****@algonet.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp