Your query can be made a lot simpler if I understand your description:

SELECT * FROM ae_articles AS art
JOIN ae_articlesections AS sec ON art.ID=sec.articleID
WHERE art.title LIKE '%bush%' AND sec.sectionID IN (1,2)

This has nothing to do with MySQL, but is a matter of knowing SQL syntax.
You can find info on joins at:
http://dev.mysql.com/doc/mysql/en/join.html

Regards, Jigal.

----- Original Message ----- 
From: "Dan Duris" <[EMAIL PROTECTED]>
To: <mysql@lists.mysql.com>
Sent: Wednesday, March 23, 2005 10:35 AM
Subject: mysql exclusion query with JOIN (request for help)


> Anyone knows who to make exclusion query when table is referenced via
JOIN:
>
> SELECT * FROM ae_articles AS art
> LEFT JOIN ae_articlesections AS sec ON art.ID=sec.articleID
> LEFT JOIN ae_articlesections AS sec2 ON art.ID=sec2.articleID
> LEFT JOIN ae_articlesections AS sec3 ON art.ID=sec3.articleID
> WHERE 1 AND (art.title LIKE '%bush%') AND sec.sectionID='1' AND
> sec2.sectionID='2' AND sec3.sectionID<>'3'
> GROUP BY art.ID
>
> This returns all articles, even those that are in section ID 3. I only
want to
> retrieve those that are in section 1 AND 2, but NOT 3! How to do this?
>
> I am absolutely stuck not knowing what to do, since MySQL does not provide
any
> examples!
>
> Thank you,
>
> Daniel
>
>
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
>
>
> !DSPAM:4241386c147615731984052!
>


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to