本文转自:

https://hdtuto.com/article/laravel-where-null-and-where-not-null-eloquent-query-example-

if you are a starter or learner laravel then you have in mind how to check where null or where not null condition using laravel eloquent model when you are writing eloquent query. if you write query for SQL then it is very easy syntax and families with where null and not null condition.

In this small tutorial i will let you know how you can write query for where null and where not null condition. here i will write core SQL query and then convert it into laravel query builder using db. So just see bellow example and see how it is works.

we have following solution on SQL and Laravel query builder:

1) IS NULL = whereNull()

2) IS NOL NULL = whereNotNull()

Where Null Query:

SQL Query:

SELECT * FROM users

WHERE name IS NULL;

Laravel Query:

DB::table('users')

->whereNull('name')

->get();

Where Not Null Query:

SQL Query:

SELECT * FROM users

WHERE name IS NOT NULL;

Laravel Query:

DB::table('users')

->whereNotNull('name')

->get();

I hope you found your best solution...

最新文章

  1. springMVC、https、GET调用别人提供的接口!!!
  2. hihoCoder#1000
  3. 第三个Sprint冲刺第三天
  4. android stuio eclipse映射下的快捷键
  5. E-Eating Together(POJ 3670)
  6. 理论沉淀:RANSAC算法
  7. Initializing a Build Environment
  8. HDU 4123 Bob’s Race 树的直径 RMQ
  9. js动态创建及移除div的方法
  10. load、save方法、spark sql的几种数据源
  11. R语言——基本绘图函数
  12. 基于arm开发板四个按键控制四个灯亮
  13. ArcGIS制图表达Representation-制图表达原理
  14. (二)php的常量和变量
  15. easyui的tree节点的获取和选中
  16. BZOJ5334 [TJOI2018] 数学计算 【线段树分治】
  17. HTML、CSS、JS 样式 (未整理)
  18. mysql数据库配置优化(占cpu过高问题)
  19. Linux VFS数据结构
  20. CF 463A && 463B 贪心 && 463C 霍夫曼树 && 463D 树形dp && 463E 线段树

热门文章

  1. kubernetes CSI 插件机制学习笔记
  2. 我的C#跨平台之旅(四):使用AOP(filter、attribute)进行系统增强
  3. mac上terminal_问题_1117
  4. vue.js 2.0(2)
  5. Python之路【第二篇】计算机组成
  6. python paramiko ssh登录交换机执行命令
  7. Maven3-依赖
  8. [转]深入理解 GRE tunnel
  9. 谈谈npm依赖管理
  10. 「ZJOI2018」历史(LCT)