jackeduphard
jackeduphard

Reputation: 42

MySQL statement search all tables for one specific column?

I am using the command line in MySQL on a Linux box.

I am logged in as root.

I need to find a field that in a table somewhere (in this schema there are 400+ tables)

Field is called 'discounts' or 'discounts'

I just need to find what table that specific field is in and if it is in more then one table with that feild or not.

Thanks for your help guys.

Edit so the db is called magento and the tables are in there.

Upvotes: 1

Views: 2645

Answers (2)

Saharsh Shah
Saharsh Shah

Reputation: 29051

Try this:

SELECT * FROM INFORMATION_SCHEMA.COLUMNS 
WHERE LOWER(COLUMN_NAME) = 'discount' or LOWER(COLUMN_NAME) = 'discounts';

Upvotes: 6

Eric Petroelje
Eric Petroelje

Reputation: 60498

Try this:

SELECT * FROM information_schema.columns WHERE column_name = 'discounts'

Upvotes: 0

Related Questions