Re: where match question

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

 



On h, 2007-01-22 at 22:53 -0800, Jim Lucas wrote:
> Don wrote:
> > I have a db field that contains zip codes separated by comas.
> > 
> > I am trying to get php to return all of the rows that contain a particular
> > zip code.
> > 
> >  
> > 
> > $query = "SELECT * FROM info WHERE MATCH (partialZIP) AGAINST ('$zip')";
> 
> try this
> 
> $query = "SELECT * FROM info WHERE column LIKE '{$zip}'";

I would use

$query = "SELECT * FROM info WHERE LOCATE('{$zip}', column) > 0";

greets
Zoltán Németh

> 
> > 
> > $result = mysql_query($query)
> > 
> > or die ("could not connect to db");
> > 
> > $row = mysql_fetch_row($result);
> > 
> >  
> > 
> >  
> > 
> > this works if there is only one row that contains that zip code.
> > 
> >  
> > 
> > If there is more than one row that contains the zip, it returns 0 rows.
> > ('It' being MYSQL that returns 0 rows. I checked this by running the query
> > directly to the DB)
> > 
> >  
> > 
> > Any ideas are very much appreciated.
> > 
> >  
> > 
> > Thanks,
> > 
> >  
> > 
> > Don
> > 
> >  
> > 
> >  
> > 
> > 
> 

-- 
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