I'm using Laravel. I make MySQL query for a search. I want to search in two columns. First, I've used:
WHERE column_name LIKE "%'.$search.'%"
But after that I decided, it's better use:
WHERE column_name LIKE ".$search."
in this way, search results would be better and exact. But when I search for example word "education", it's throwing Queryexception:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'education' in 'where clause - ...WHERE column_name LIKE education'
What's wrong with my query?
Add quotes for string value:
WHERE column_name LIKE '".$search."'
Query will looks like this:
$query = "SELECT ... WHERE column_name LIKE '" . $search . "' ... ";