Reputation: 3809
How might I find something that is not like a certain string.
SELECT * FROM users WHERE username NOT LIKE '%ray%';
Upvotes: 54
Views: 77123
Reputation: 3809
There are a few different options depending on your needs. You can use any of the following to find something that is not like a certain string:
Users::where('username', 'not like', "%ray%")->get();
DB::table('users')->where('username', 'not like', '%ray%');
Capsule::table('users')->select('*')->where('username', 'not like', '%ray%')->get();
Upvotes: 9
Reputation: 804
Use DB facade
$data = DB::table('users')->select('*')->where('username', 'not like', '%ray%')->get();
Also you can use
$data = User::where('username', 'not like', "%ray%")->get();
Upvotes: 4
Reputation: 1582
Simply you can use the model to get that result
User::where('username', 'not like', "%ray%")->get();
Upvotes: 135