I have this code:
mysql_query("
SELECT id as tc_id, firstname, surname, position, @concat := CONCAT(firstname,' ',surname)
FROM tc
WHERE (@concat LIKE '%". mysql_real_escape_string($_REQUEST['search_term']) ."%');");
search_term just refers to the value of a text input.
When I run the SELECT statement in sequel pro locally – my mysql program – it works perfectly, selecting the appropriate rows. When I run the query however locally through my PHP page, it returns no rows, even though it should. Help anyone?
WHEREdoes not work on calculated columns, therefore your query, per se, will not work.It probably works because you locally have a
@concatvariable declared. It will also appear to work if you run the query twice in specific conditions, because your query might actually assign a@concatvariable.What you want is
As test: