没有条件时,如何使查询不返回任何内容? [英] How do I make a query return nothing when there are no conditions?

查看:86
本文介绍了没有条件时,如何使查询不返回任何内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

相当简单,我有一对多/多对一的关系,我想查询一下.但是,当WHERE子句信息未提供时,我不希望返回任何结果.

Rather simple, I have a one to many / many to one relation and I'd like to query it. However, I don't want any results returned when it isn't provided with any WHERE clause information.

简单来说,如何使查询变得非贪婪?

In simpler terms, how do I make a query non-greedy?

推荐答案

您可以添加一个始终为false的where子句,并附加您希望随OR提供的条件:

You could add a where clause that is always false and append the condition you want supplied with OR:

select * from table where 1 = 0 OR (real conditions)

这篇关于没有条件时,如何使查询不返回任何内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆