Can't you do without REGEX? eg WHERE employ_id = '($employ_id)' OR company LIKE '($name)' REGEXes are expensive. Ignatius _________________________ ----- Original Message ----- From: "Shannon Doyle" <shannon@wyattgroup.com.au> To: <php-db@lists.php.net> Sent: Thursday, October 09, 2003 10:18 AM Subject: REGEXP and Variables. > Hi People, > > Need a little assistance with the following MySQL query:- > > $query = "SELECT employ_id,company FROM employers WHERE employ_id REGEXP > '($employ_id)' OR company REGEXP '($name)' OR industry REGEXP > '($industry)'"; > > The above query gets the variables $employ_id, $name and $industry from > a search box on a previous page. I can confirm that the variables are > being parsed to the query. > > The problem is that the above query appears to match everything in the > table, from any of the fields and thus just dumps out the entire > contents of the table, instead of only selecting the ones that match the > search criteria. > > Basically I have a variable passed to the query and it must return the > values from the table that have the variable in its entirety somewhere > in the fields value. > > > In addition to this, once I have it selecting the correct values and > returning them to me. What can I do to show a 'No Results' situation? > > Any help woul dbe gratly appreciated. > > Cheers, > > Shannon > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php