How can I go about querying a MySQL column that contains white spaces within the value when my query sometimes does not contain a white space?
My example is:
Query: select * where postcode = 'SW1A2AA'
Data structure:
id | postcode | address
1 SW1A 2AA 10 downing street, london, SW1A 2AA
I am using laravel as the backend and i have tried to use %like% and also %%like%% using a raw query but for some reason nothing seems to work.
my basic query is:
public function lookup($postcode){
$db = postcodeLookup::where('postcode', $postcode)->get();
return $db;
}
This works fine as long as the postcode query is the same as the value stored in the DB, So if my query contains spaces it simply returns null.
Any help is greatly appreciated, Thanks.