Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Database 从多个表名中选择列名_Database_Postgresql 9.1 - Fatal编程技术网

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'))