Re: If MySQL column/field values are in an PHP array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I think you want OR instead of AND in your query...

It will be very dificult for both:
name+city+state
name
to be in your list of cen_chiefs...

cen_chiefs would have to have *both*:
Joe Chicago IL
Joe
in it, in order for Joe from Chicago, IL to match with AND.

OR would get rows where either their name OR their name/city/state
matched up.

On Thu, July 19, 2007 7:33 am, kvigor wrote:
> I created an array using the following:
>
> $in_list = "'".join("','",$cen_chiefs)."'"; //$cen_chiefs is an array
>
> $query_cen_chiefs = "SELECT * FROM central WHERE CONCAT(strName,'
> ',strCity,' ',strState) IN({$in_list})";
>
> How would I go about adding an AND clause to the above query to return
> all
> rows where strName column values are in $in_list array
>
> I acutally did the above w/ "SELECT * FROM central WHERE
> CONCAT(strName,'
> ',strCity,' ',strState)
> IN({$in_list}) AND (strName) IN({$in_list}) ORDER BY conName"; // This
> return zero rows.
>
> I think I Should I be using strName as a pattern, because strName
> would be a
> partial value of $in_list array values?
>
> Something like: REGEXP '^.....$'
>
> "SELECT * FROM central WHERE CONCAT(strName,' ',strCity,' ',strState)
> IN({$in_list}) AND (REGEXP '^strName$') IN({$in_list}) ORDER BY
> conName";
> //This query doesn't work by the way.  This is where I'm stuck.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux