I've built a simple search bar for my website, and if my query looks like this, it works great:
$sql = query("SELECT id, firstname, lastname, username, location FROM
users WHERE firstname LIKE '%" . $search_query . "%' LIMIT 20");
but if i write it like that, it echoes a SQL Syntax error :
$sql = query("SELECT id, firstname, lastname, username, location FROM
users WHERE firstname, lastname, username, location LIKE '%" . $search_query . "%'
LIMIT 20");
The difference between the 2 queries is that the 2nd one will search through multiple columns which is what i need since my users can search either for a name or a city.
How should I re-write it ?