仅返回查询中的表,而不返回视图

时间:2017-10-06 01:08:16

标签: mysql sql

如何编写以仅返回列名为'employee_no'的DB中存在的表,以便我可以说

SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME like '%employee_no'

但这也会返回视图,我只想要实际的表格。

之类的东西?

 SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME like '%employee_no' and WHERE TYPE = 'U'

1 个答案:

答案 0 :(得分:3)

您可以查看TABLES.TABLE_TYPE

SELECT c.*
FROM INFORMATION_SCHEMA.COLUMNS c JOIN
     INFORMATION_SCHEMA.TABLES t
     ON c.table_name = t.table_name AND
        c.table_schema = t.table_schema
WHERE c.COLUMN_NAME like '%employee_no' AND
      t.table_type = 'BASE TABLE';