Database 从多个表名中选择列名
当我尝试Database 从多个表名中选择列名,database,postgresql-9.1,Database,Postgresql 9.1,当我尝试 select column_name from information_schema.columns where table_name= ('TableA') 它工作得很好,但当我尝试对同一数据库中的选定表执行相同的操作时,它不起作用 select column_name from information_schema.columns where table_name= ('tableA', 'TableB') 我认为您的查询应该是:selectcolumn\u name fro
select column_name from information_schema.columns where table_name= ('TableA')
它工作得很好,但当我尝试对同一数据库中的选定表执行相同的操作时,它不起作用
select column_name from information_schema.columns where table_name= ('tableA', 'TableB')
我认为您的查询应该是:
selectcolumn\u name from information\u schema.columns where table\u name=('tableA')或table\u name=('TableB')
,或者selectcolumn\u name from information\u schema.columns where table\u name in('tableA','TableB')
,但不确定postgresql是否支持第二个
expression IN(value[,…])是expression=value1或expression=value2或…,的简写符号
(强调矿山)
所以你可以两者都用
where table_name = ('tableA') or table_name = ('TableB')
如Gi1ber7所示,以及
where table_name in ('tableA','TableB')
- 以上是相等的
如果您想使用<代码>=<代码>运算符,请考虑使用<代码>任何(数组)< /代码>:
甚至任何(子查询):where table_name = ANY(ARRAY['tableA','TableB'])
where table_name = ANY(VALUES ('tableA'),('TableB'))