0
我有一個special_number
表與前綴列。該列包含022
,021
等數據。我有一個號碼0216627363021
。我如何使用LIKE
關鍵字匹配列以獲取該行。Laravel 5查詢`LIKE`問題
$rate = Special::where('user_id',$user_id)
->where(DB::raw("prefix LIKE $number"))
->orWhere(DB::raw("prefix LIKE SUBSTR($number,1,-1)"))
->orWhere(DB::raw("prefix LIKE SUBSTR($number,1,-2)"))
->orWhere(DB::raw("prefix LIKE SUBSTR($number,1,-3)"))
->orWhere(DB::raw("prefix LIKE SUBSTR($number,1,-4)"))
->orWhere(DB::raw("prefix LIKE SUBSTR($number,1,-5)"))
->orWhere(DB::raw("prefix LIKE SUBSTR($number,1,-6)"))
->orWhere(DB::raw("prefix LIKE SUBSTR($number,1,-7)"))
->orWhere(DB::raw("prefix LIKE SUBSTR($number,1,-8)"))
->orWhere(DB::raw("prefix LIKE SUBSTR($number,1,-9)"))
->orWhere(DB::raw("prefix LIKE SUBSTR($number,1,-10)"))
->first();
但它返回NULL。哪裏有問題?謝謝。