I'm calling a Procedure from the PHP form, which the user inputs an Address or Postcode to search on in order to return details around the customer.
My issue is that within my WHERE clause I've set the fields to search LIKE the input, but when I open my search form it returns all rows from the table, when this WHERE clause below is used.
WHERE (AddressLine1 LIKE CONCAT('%', street_name, '%')) OR (Postcode LIKE CONCAT('%', post_code, '%'))
If I changed it and the user put the specific Postcode or Address like below,
WHERE ((Postcode = post_code OR street_name IS NULL)
OR (AddressLine1 = street_name OR post_code IS NULL))
then the search page would return no rows of data until the query had run. How can I stop the query from showing all rows in the table until the query has run?
CALL sp_jobsearch('".$searchpostcode."', '".$searchaddress."');