andyandy
1 month ago

%LIKE% but prefer exact match

Posted 1 month ago by andyandy

I have this:

$dbData = City::where('name', 'like', '%'.$data.'%')->limit(10)->get();

I want to prefer exact match on the first place.

Eg. searching for CAT will give CAT on first place and CATegory on second... .

Please sign in or create an account to participate in this conversation.