本文介绍了SQL select语句在where子句中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,我正在尝试执行查询,但似乎无法正确执行.
Hi there I am trying to execute a query but cannot seem to get it right.
SELECT *
FROM table
WHERE id IN (SELECT *
FROM table
WHERE description = 'A')
AND description = 'B'
上面是我得到的查询,select * from table where description = A
在单独运行时按预期工作,我只需要使where子句起作用,这样我就可以看到具有A和B描述的任何ID.
Above is the query that I have got, the select * from table where description = A
works as expected when ran alone I just need to make the where clause to work so I can see any id that has a description of A and B.
推荐答案
当我假设只需要id列时,您将从子查询中获取多个列:
You will be getting multiple columns from the sub query when I assume you only want the id column:
SELECT *
FROM table
WHERE id IN (SELECT id
FROM table
WHERE description = 'A')
AND description = 'B'
这篇关于SQL select语句在where子句中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!