Monday, 26 August 2013

Select table from database where value is X

Select table from database where value is X

So far I've found out that this gives me a list of all the tables which
has the column name "store_id" - but I only want it to select the columns
if "store_id" = 4, how could I do this?
Right now I use this to find the tables which has the "store_id" column.
SELECT DISTINCT TABLE_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME IN ('store_id')
AND TABLE_SCHEMA='db1';

No comments:

Post a Comment