【发布时间】:2014-07-28 00:56:30
【问题描述】:
Have accountId ={001,3456,78902,456}
我想使用IN 子句和left join on 操作从现有表中获取这些accountId 的详细信息,我应该如何形成查询?作为 DB 端的新手,我无法将正确的部分组合在一起:
select t1.col2, case when CASE WHEN t1.col3 is null THEN 'False' ELSE 'True' END as value
FROM table2 t2 left join table1 t1 on t2.col1=t1.col1
WHERE accountID IN (001,3456,78902,456); //The query is wrong because, I wanted to map using those accountID and get the data?
任何关于形成查询的快速帮助都会很棒
现有表将accountId 作为列之一。
【问题讨论】:
-
accountid是哪个表的一部分?始终提供表定义和您的 Postgres 版本以及此类问题。并解释您要达到的目标。
标签: sql postgresql in-clause