如何将 SELECT EXISTS() 查询链接在一起?
我有一个简单的查询,
SELECT EXISTS(SELECT a FROM A WHERE a = 'lorem ipsum');
如果 A 中存在包含“lorem ipsum”的行,它将返回 0 或 1
我想将此行为链接在一起。所以我会得到多行,如果该值存在,每行都有 0 或 1。
我该怎么做呢?
更新:
可以这样做,但随后我会得到每个结果的一列。
SELECT EXISTS(SELECT a FROM A WHERE a = 'lorem ipsum'), EXISTS(SELECT a FROM A WHERE a = 'dolor sit');
I have this simple query
SELECT EXISTS(SELECT a FROM A WHERE a = 'lorem ipsum');
That will return a 0 or 1 if there exists a row in A that contains 'lorem ipsum'
I would like to chain this behavior together. So I would get multiple rows, each with a 0 or 1 if that value exists.
How would I go about doing this?
Update:
It's possible to do it like this but then I get a column for each result.
SELECT EXISTS(SELECT a FROM A WHERE a = 'lorem ipsum'), EXISTS(SELECT a FROM A WHERE a = 'dolor sit');
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
或者
Or
手头没有 SQL 服务器,但请尝试以下操作:
Don't have an SQL server handy, but try this:
我会用这样的东西。
I would use something like this.