Re: Searching the database
| From: | Joe Kaiping | Date: | Sat, 06 Oct 2001 19:32:42 +0000 |
| Subject: | Re: Searching the database | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-70243@lists.php.net to get a copy of this message | ||
Hi Mick,
The % wildcard (like _) can be used in more than one place in the search
string. (e.g. LIKE '%$artists%').
You might want to check out
http://www.mysql.com/doc/P/a/Pattern_matching.html
and maybe even more useful for you:
http://www.mysql.com/doc/F/u/Fulltext_Search.html
Also the mailing lists mysql@lists.mysql.com and php-db@lists.php.net might
be more useful for this kind of help.
-Joe
mick@night-owl.co.uk (Mick Fitzpatrick) wrote:
Hello
My first attempt at building a PHP/MySql database is proving to be very
'interesting' :-)
I would like to know how to make it search for words mid sentence ... at the
moment it will only look at the begining of each entry. So if I type in
Michael it will display Michael David Smith, Michael Andrew Jones etc etc.
However, If I type David ... nothing is displayed.
I believe this is the line that defines how the database is searched and I
believe the fix needs to be there ... but I don't know how to! ... so any
advice will be appreciated:
$result = mysql_query ("SELECT * FROM example WHERE artists LIKE '$artists%'
AND aside LIKE '$aside%' ORDER BY name ASC");
TIA ... Mick