I'm trying to find an exact phrase but for some reason, it finds matches with additional words , here is the code :
$subLocationId = DB::select(
DB::raw(' SELECT id FROM sub_location WHERE match(sub_location_name) against("' .
$subLocationName . '" IN BOOLEAN MODE ) ' )
);
above is Laravel ORM query , and here is regular mysql:
' SELECT id FROM sub_location WHERE match(sub_location_name)
against("' .$subLocationName . '" IN BOOLEAN MODE ) '
I input : "Business Bay" but it matches "53 Business Bay" , I'd like it to match only "Business Bay" without any extra word from front or behind
Why don't you just use
$subLocationId = DB::select(
DB::raw("SELECT id FROM sub_location sub_location_name='" . $subLocationName. "'" )
);
You can easily achieve it with the following query:
\DB::table('sub_location')
->select(['id'])
->where('sub_location_name', $subLocationName);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.