Searching MySQL tables with LIKE

From: Date: Wed, 07 Feb 2001 21:01:53 +0000
Subject: Searching MySQL tables with LIKE
Groups: php.general 
Request: Send a blank email to php-general+get-38616@lists.php.net to get a copy of this message
Hi Guys, Just a quick question. I've been using an sql query like this (using wildcards): $sql = "SELECT * FROM table WHERE $search_criteria LIKE '%$search_input%' ORDER by $search_criteria ASC"; At the moment, if the search criteria was "First_Name" and the text ($search_criteria) was "ch", the returned query contains any name containing "ch". The trouble is, if the name you are after is Chris ...., you might get a result like: id 1 CHris etc etc id 2 RiCHard etc etc id 3 CHris etc etc In other words, it seems to be sorting where the instance of the CH comes in id number rather than alphabetically. Is there a way of making the query (using wildcards or without) if someone types in "a", the list will return alphabetically with, like: a aa ab abc ac ace ade I'd explain more, but I really have to go. Sorry. Hope you can help, as most of you often do :) James

« previous php.general (#38616) next »