jimlongo Posted November 2, 2020 Share Posted November 2, 2020 (edited) I need to check that column 'username' both IS NOT NULL and != "" What is best ->where('username','!=','') ->whereNotNull('username') OR ->whereNotIn('username',[NULL,'']) or something else . . . What do you think? Edited November 2, 2020 by jimlongo 0 Quote Link to comment Share on other sites More sharing options...
jimlongo Posted November 3, 2020 Author Share Posted November 3, 2020 on further though and checking straight MYSQL, you cannot do a query with NULL. = NULL != NULL IN(NULL) NOT IN (NULL) will not return any results. Since Eloquent is a mapping tool to MYSQL queries I'm gonna say that the second proposal above doesn't make sense. You need to check NOT NULL, and != separately. Don't know of any way to prove it, other than the fact that ->whereNotIN('field',[NULL]) doesn't work in my code. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 4, 2020 Share Posted November 4, 2020 I would have thought that you could use... ->where('username','!=','') ->whereNotNull('username') that wherenotin array wouldn't work with a query builder. 0 Quote Link to comment Share on other sites More sharing options...
jimlongo Posted November 4, 2020 Author Share Posted November 4, 2020 Yes, that's what i tried to say in the post above, perhaps rather "ineloquently" 🙂 Thanks. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.