문제

Probably an easy question.. I've got a list of tables from INFORMATION_SCHEMA and I want to do queries (select, delete etc) on the data within these tables:

I tried

Select * from (SELECT DISTINCT TABLE_NAME 
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE COLUMN_NAME = 'Col1')

But of course it does not work..

도움이 되었습니까?

해결책

You have to provide the alias for the table clause after FROM and in SELECT like q.*

SELECT q.* FROM (SELECT DISTINCT TABLE_NAME 
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME = 'Col1') q

All you can see from INFORMATION_SCHEMA is

SELECT q.* FROM (SELECT * 
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME = 'id') q

But for data you have to reference the database with table name separately

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top