OR in WHERE

Ruslan Zasukhin sunshine at public.kherson.ua
Thu May 20 18:02:06 CDT 2004


On 5/20/04 5:46 PM, "Andrew Sinning" <andrew at learningware.com> wrote:

> I never saw a response from the question below.  Ruskin, can you please
> help me out?
> 
> Thanks.
> 
> Andrew
> 
> -----Original Message-----
> From: valentina-bounces at lists.macserve.net
> [mailto:valentina-bounces at lists.macserve.net]On Behalf Of Andrew Sinning
> Sent: Monday, May 17, 2004 12:27 PM
> To: Valentina Developers
> Subject: OR in WHERE
> 
> 
> I think that I've read that this is broken, but I'm just not smart
> enough to think of another way to write this sql statement.  Perhaps
> with a little help I'll catch on.
> 
> I have two tables 'questions' and 'infos'.
> 
> questions.infoId
> and
> questions.introId
> 
> can either be related to infos.iId
> 
> I want to find all the info that correspond to either an infoId OR an
> introId in questions
> 
> -- looking for JUST the infoId's, works just fine:
> sql = "SELECT iId FROM infos, questions WHERE questions.infoId =
> infos.iId"
> put dbQuery(sql)
> -- [[#iID: 98], [#iID: 101], [#iID: 94], [#iID: 73], [#iID: 74], [#iID:
> 75], [#iID: 76], [#iID: 77], [#iID: 78], [#iID: 79], [#iID: 80], [#iID:
> 81], [#iID: 82], [#iID: 83], [#iID: 84], [#iID: 85], [#iID: 86], [#iID:
> 87], [#iID: 88], [#iID: 89], [#iID: 90], [#iID: 91], [#iID: 92]]
> 
> -- looking for JUST the introId's, works just fine:
> sql = "SELECT iId FROM infos, questions WHERE questions.introId =
> infos.iId"
> put dbQuery(sql)
> -- [[#iID: 96], [#iID: 99], [#iID: 93]]
> 
> 
> BUT, now I need to combine the two, and I get no result:
> sql = "SELECT iId FROM infos, questions WHERE (questions.infoId =
> infos.iId) OR (questions.introId = infos.iId)"
> put dbQuery(sql)

If I have understand correctly query must be

    SELECT iId 
    FROM infos, questions A, questions B
    WHERE 
        A.introId = infos.iId AND
        infos.iId = A.infoId


-- 
Best regards,
Ruslan Zasukhin      [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com

To subscribe to the Valentina mail list go to:
http://lists.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------



More information about the Valentina mailing list