Quantcast
Channel: SQL list all tables with certain column names - Stack Overflow
Browsing all 3 articles
Browse latest View live

Answer by Filipe Paulo for SQL list all tables with certain column names

Use this:SELECT DISTINCT TABLE_NAMEFROM information_schema.COLUMNS WHERE COLUMN_NAME = 'field1' OR COLUMN_NAME = 'field2'This should return EVERY table name which has a column named 'field1' or 'field2'.

View Article



Answer by Zohar Peled for SQL list all tables with certain column names

Try this:SELECT DISTINCT T1.TABLE_NAMEFROM INFORMATION_SCHEMA.COLUMNS T1INNER JOIN INFORMATION_SCHEMA.COLUMNS T2 ON(T1.TABLE_NAME = T2.TABLE_NAME)WHERE T1.COLUMN_NAME = 'field1'AND T2.COLUMN_NAME =...

View Article

SQL list all tables with certain column names

I'd like to make a SQL query to a MySQL 5.6 server to return me all the tables that contains AT LEAST the following column names:field1 field2I've seen examples here but they only cover having exactly...

View Article
Browsing all 3 articles
Browse latest View live




Latest Images