I have a table with highschools in different cities. I want to give the user the option to choose a certain city and view the schools there, or view all schools. This is my original query:
SELECT * FROM highschools
WHERE city = '$givenCity'
I need to compare 'city' to '$givenCity' only if '$givenCity' has any value.
The closest i have come to solving my problem is writing :
Where city = '$givenCity' AND '$givenCity' != 'NULL'
When I read this now, it seems so wrong...
Do you know how can I do this? And can it be done in one query?