[英]Query All Tables In A Database
I am surely just askewing my and statement here. 我肯定只是在这里歪曲我的声明。 I want to get a list of all tables that meet both conditions (but it returns 0).
我想获得满足两个条件的所有表的列表(但它返回0)。 If I run each statement individually they each return multiple tables, but adding the and into the query 0 tables are returned (which I know is incorrect).
如果我单独运行每个语句,它们每个都返回多个表,但是返回并在查询中返回0表(我知道这是不正确的)。 What do I need to change to get this to execute successfully?
我需要更改什么才能成功执行此操作?
Works 作品
select
table_name, column_name
from
information_schema.columns
where
column_name ILIKE 'Man%'
Works 作品
select
table_name, column_name
from
information_schema.columns
where
column_name ILIKE 'sale%'
Returns 0 results 返回0结果
select
table_name, column_name
from
information_schema.columns
where
(column_name ILIKE 'man%'
and column_name ILIKE 'sale%')
order by
table_name asc
I want to return tables that have a column that begins with man
AND a column that begins with sale
only. 我想返回具有以
man
开头的列和仅以sale
开头的列的表。 Is there a way to achieve this result? 有没有办法实现这个结果?
You could do something like this 你可以这样做
select a.table_name,a.column_Name,b.column_Name from
(select table_name, column_name
from information_schema.columns
where column_name ILIKE 'Man%') a,
(select table_name, column_name
from information_schema.columns
where column_name ILIKE 'sale%')b
where a.table_name=b.table_name
order by a.table_name asc
As I said, I'm not familiar with postgresql so this may not work. 正如我所说,我不熟悉postgresql所以这可能不起作用。 :)
:)
select a.table_name, a.column_name, b.column_name
from information_schema.columns a
join information_schema.columns b on a.table_name=b.table_name
where (a.column_name ILIKE 'man%'
AND b.column_name ILIKE 'sale%')
ORDER BY table_name ASC
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.