Re: [PHP] mySQL WHERE/LIKE
The only way I know how to do it is by doing boolean OR's... It's not as compact and efficient as you'd like, but it works. SELECT * FROMgallery LEFT JOIN designers ON (designers.designersID=gallery.designersID) WHERE (gallery.column1 LIKE '%$search_string%' OR gallery.column2 LIKE '%$search_string%') ORDER BYgallery.galleryID"; Wilbert Enserink wrote: > Hi all, > > I know this is rather OT, but I searched the mySQL manual all over...couldn't find it. > I want to perform a search in a table. More then 1 columns should be searched. namely column1 and column2 and so on. > Anybody knows what goes wrong here? --(in the WHERE clause). It seems that mySQL doesn't like to perform a search in more then 1 column.:-( > > $query="SELECT * FROM gallery LEFT JOIN designers ON (designers.designersID=gallery.designersID) WHERE (gallery.column1, gallery.column2) LIKE '%$search_string%' ORDER BY gallery.galleryID"; > > > > thx for any advice > > - > Pas de Deux > Van Mierisstraat 25 > 2526 NM Den Haag > tel 070 4450855 > fax 070 4450852 > http://www.pdd.nl > [EMAIL PROTECTED] > - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mySQL WHERE/LIKE
On Thursday 23 May 2002 22:20, Wilbert Enserink wrote: > Hi all, > > I know this is rather OT, but I searched the mySQL manual all > over...couldn't find it. Why not ask on the mysql list !?! > I want to perform a search in a table. More then 1 > columns should be searched. namely column1 and column2 and so on. Anybody > knows what goes wrong here? --(in the WHERE clause). It seems that mySQL > doesn't like to perform a search in more then 1 column.:-( > > $query="SELECT * FROM gallery LEFT JOIN designers ON > (designers.designersID=gallery.designersID) WHERE (gallery.column1, > gallery.column2) LIKE '%$search_string%' ORDER BY gallery.galleryID"; WHERE column1 LIKE '%something%' AND column2 LIKE '%something%' ... Also use parantheses where necessary. -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* If you think the pen is mightier than the sword, the next time someone pulls out a sword I'd like to see you get up there with your Bic. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php