IS IN(选择语句,'值','值')

时间:2010-12-01 10:47:33

标签: tsql select

我正在尝试运行以下SQL

DELETE FROM T_ATH_POSHLD WHERE T_ATH_POSHLD.A_INSID IN (SELECT T_ATH_POSHLD.A_INSID FROM T_ATH_POSHLD LEFT JOIN T_ATH_INS ON T_ATH_POSHLD.A_INSID = T_ATH_INS.A_INSID WHERE T_ATH_INS.A_INSCLSCDE1 = 'CASH' AND T_ATH_POSHLD.A_INSID NOT IN (SELECT A_INSID FROM T_ATH_CCY) AND A_ACCID IN (SELECT A_ACCID FROM T_ATH_EXTACC, '1212OEIC', '5667033ZS'))

,特别是,我试图检查一个ACCID是否在一组值中,一些来自一个表和两个硬编码。我怎么做到这一点?

IN (SELECT A_ACCID FROM T_ATH_EXTACC, '1212OEIC', '5667033ZS')

不起作用,我收到'错误的语法错误'。

由于

2 个答案:

答案 0 :(得分:2)

您需要使用UNION将2个硬编码值添加到要传递给in子句的结果集中。

IN (SELECT A_ACCID FROM T_ATH_EXTACC UNION ALL SELECT '1212OEIC' UNION ALL SELECT '5667033ZS')

答案 1 :(得分:0)

IN (SELECT '1212OEIC', '5667033ZS', A_ACCID FROM T_ATH_EXTACC )