我有一张产品表。一栏包含这些产品的失效日期。 如果他们没有这样的到期日,则会写上“' - ' 。 我想获得过期产品的ID,我有以下问题:
声明:
SELECT id from product where
(select expiry from product where expiry not in ('-')) < GETDATE()
错误:
Subquery returned more than 1 value. This is not permitted when the subquery
follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
如何获得符合上述条件的产品?
答案 0 :(得分:4)
您无法以这种方式将一个值与多个值进行比较。我怀疑你真正想要的是:
SELECT id
FROM product
WHERE expiry < GETDATE()
AND expiry <> '-'