select * from 表 where (字段=条件 or 条件='') 当条件不为空时sql语句等价于:select * from 表 where 字段=条件; 当条件为空时SQL语句等价于:s
select * from 表 where (字段=条件 or 条件='')
当条件不为空时sql语句等价于:select * from 表 where 字段=条件;
当条件为空时SQL语句等价于:select * from 表 where ''='';
这样就实现了当查询条件为空时默认查询全部数据,当查询结果非空时则查询对应的数据。
edge:(where条件)
where f_name like '%${name}%' and (f_status=#{status} or #{status}='') and (f_data_node=#{dataNode} or #{dataNode}='') and (f_warehousing_scheme like '%${warehousingScheme}%' or '%${warehousingScheme}%' like '%%')")
来源地址:https://blog.csdn.net/Jiang5106/article/details/129795818
--结束END--
本文标题: SQL语句当查询条件为空时默认查询全部数据,不为空是则按照条件进行查询
本文链接: https://www.lsjlt.com/news/421327.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0