From: Ed Curtis [mailto:[EMAIL PROTECTED]

>  I've been challenged to write a matching query in a project 
> and do not know how to handle a part of it. The criteria are 
> as follows:
> 
> SELECT * from pages WHERE
> 
> changelog.agent = pages.agent AND
> changelog.company = pages.company AND
> changelog.magazine = pages.magazine
> 
> Now for the challenging part for me at least.
> 
> one of the following must at least be true for the query to 
> return a result.
> 
> changelog.orig_id = pages.mls_1
> changelog.orig_id = pages.mls_2
> changelog.orig_id = pages.mls_3
> changelog.orig_id = pages.mls_4
> changelog.orig_id = pages.mls_5
> changelog.orig_id = pages.mls_6
> changelog.orig_id = pages.mls_7
> changelog.orig_id = pages.mls_8
> changelog.orig_id = pages.mls_9
> changelog.orig_id = pages.mls_10
> changelog.orig_id = pages.mls_11
> changelog.orig_id = pages.mls_12
> 
> Would I nest these as an OR statement and how would I go about it?


This is untested, but I imagine you could do the following:

SELECT * from pages 
WHERE changelog.agent = pages.agent 
AND changelog.company = pages.company 
AND changelog.magazine = pages.magazine
AND changelog.orig_id IN (
        pages.mls_1, pages.mls_2, pages.mls_3, 
        pages.mls_4, pages.mls_5, pages.mls_6, 
        pages.mls_7, pages.mls_8, pages.mls_9, 
        pages.mls_10, pages.mls_11, pages.mls_12
);


-- 
Mike Johnson
Web Developer
Smarter Living, Inc.
phone (617) 886-5539

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

Reply via email to