If your three php vars are p1, p2, p3 and the three cols are f1, f2, f3,
don't you just need ...

    SELECT ...
    WHERE f11 IN ( p1, p2, p3 )
        OR f2 IN ( p1, p2, p3 )
        OR f3 IN ( p1, p2, p3 )

PB

-----

> I have an enigma that I just can't seem to resolve.
>
> ==================
> What is Hoped For:
> I have 3 variables (called F1, F2 and F3) which will contain either an
> integers (a pointer to a "feeback" item in another table, actually) and a
> database of questions, each having an F1, F2 and F3, any one or more of
> which can contain an integer or 0 (for null).
>
> What I hope to do is do a comparison like this:
>
> $myquery=MYSQL_QUERY("select count(uid) from TABLENAME where  ( (F1='$F1')
> || (F2='$F1') || (F3='$F1') || (F1='$F2') || (F2='$F2') || (F3='$F2') ||
> (F1='$F3') || (F2='$F3') || (F3='$F3')      )        ");
>
> In other words I wish to find out if one or more of three variables that
may
> contain an integer, matches any questions with feedback items F1, F2 and
F3
> (integers all).  The variable F1 can match F1, F2 or F3 in the database,
so
> all comparisons must be tried.
> ==================
>
> The Problem:
>
> Again, there are three fields in a table, F1, F2, and F3.  They are
numeric.
> There are three variables passed by a php program, and I want to know if
any
> one of F1, F2 or F3 matches any one of F1, F2 or F3 in the table.  Again,
> since the variable F1 can match F1, F2 or F3 in the database, I want to do
> all comparisons.
>
> So using PHP I do this:
>
> //set one variable to an integer (in the program being written, this may
> occur naturally)
> $F1='' $F2=2; $F3='';
>
> //test to see if any of F1, F2 or F3 are set to some integer (otherwise it
> is set to nothing at all)
> $F1index=is_numeric($F1); //if F1 is numeric set F1index to "1"
> $F2index=is_numeric($F2); //if F2 is numeric set F2index to "1"
> $F3index=is_numeric($F3); //if F3 is numeric set F2index to "1"
>
> //Set any null values to some specific value (part of my efforts to
resolve
> the problem below)
> if ($F1index <1){$F1='WWW';}
> if ($F2index <1){$F2='WWW';}
> if ($F3index <1){$F3='WWW';}
>
> //The situation here is that the variable F1 is WWW and F2=2 and F3 is
WWW.
> In the database table there are 2 rows in which F1 is 0, F2=3 and F3=0.
>
> $data=MYSQL_QUERY("select count(F1) from TABLENAME where  (F1='$F1') ||
> (F1='$F2') || (F1='$F3') ");
> //In the database, F1=0, F2=3 and F3=0.  therefore, the above query
results
> in NO match, which is the case.  Perfect.
>
> BUT (and here is the rub) if I do this:
>
> $data=MYSQL_QUERY("select count(uid) from TABLENAME where  ( (F1='$F1') ||
> (F2='$F1') || (F3='$F1') || (F1='$F2') || (F2='$F2') || (F3='$F2') ||
> (F1='$F3') || (F2='$F3') || (F3='$F3')      )        ");
> //BOTH records in the table match successfully.  I thought that none ought
> to match as variable F1, F2 and F3 are all NOT 3.
>
> //wondering what is going on I tried a scaled-down, simpler query
> $data=MYSQL_QUERY("select count(F1) from QQwowen where  (F1='$F1') ||
> (F1='$F2') || (F1='$F3') || (F2='GOOOBAAA') ");
> //I put something ridiculous ('Gooobaaa') to compare to F2 (F1=0, F2=3 and
> F3=0 in the table) and
> this query matches ALL records in the table.
>
> I'm certain that I'm missing something fundamental here.  Can anyone
explain
> to me why this is happening?
>
> Thanks very much!
>
> Cheers!
>
> -warren
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
<[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
>
>



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to