mercredi 15 janvier 2020

Eloquent won't return row where('foo', '!=', 'bar') if foo is NULL [duplicate]

I have this query in Laravel 5.7:

users = User::where('role', 'sales')
            ->where('tasks', '!=', 'lead')
            ->orderBy('last_name')
            ->get();

I expected this query to get all users that have the sales role, unless they are marked as lead in the tasks column (which may be NULL). But now I had to realize that in my app, whenever tasks is NULL, the user won't be part of the collection.

Is this usual behaviour? If so, how should I approach this problem? If not, what might cause it?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/36XXYro
via IFTTT

Aucun commentaire:

Enregistrer un commentaire