1
0

More than 3 years have passed since last update.

[Laravel]キーワードが含まれて”いない”レコードをDBから取得する方法

Last updated at Posted at 2021-03-28

キーワードが含まれていないレコードをDBから取得する方法


//Eloquent Model を使用する形
$users = User::where('column名', 'not like', '%'.$keyword.'%')->get();

//Eloquent Model を使用しない形
$users = DB::table('users')->where('column名', 'not like', '%'.$keyword.'%')->get();

一言

Laravel公式ドキュメントにも日本語翻訳版ドキュメントにもないため記事化しました。
sql知ってる人からすると当然こうなるのでドキュメントにはないのでしょうね。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0