you can try to remove whitespace and add simply your code
$jobs->where('CollPCode','LIKE','%'.$colpostcode.'%')
->orWhere('CollPCode','LIKE','%'.preg_replace('/\s+/', '', $colpostcode).'%');
Hey , Thanks but I do not think this works in both situations. For example if the DB entry has a space "B37 7GT" , then if user searches "B377GT" it will not find the version with a space in the DB? I need to strip the DB version of whitespaces on the where also no?
you dont want a like, you need a regexp something like:
select 'b377gt' REGEXP '[[:alnum:]][[:blank:]]*[[:alnum:]]{3}';
so it will match both with/without spaces
Thanks Shez, how would i put that into a query?
if(!empty($ColDate)){
$jobs->where('ColDate',$ColDate);
}
$jobs->where('CollPCode','LIKE','%'.$colpostcode.'%');
should be: $jobs->where('CollPCode','REGEXP','pattern');
use replace, $jobs->orWhereRaw('REPLACE (CollPCode," ","") LIKE "%'.str_replace(' ','%',$colpostcode).'%"')
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community