I'm trying to find if my database has a column named sort_method
. I have had a look around the forums, but I don't seem to be able to find the right answer. My database has over 300 tables, so manually looking for it is not an option.
I'm using SQL queries from phpMyAdmin.
Find duplicate values in one column First, use the GROUP BY clause to group all rows by the target column, which is the column that you want to check duplicate. Then, use the COUNT() function in the HAVING clause to check if any group have more than 1 element. These groups are duplicate.
You want to look for tables using the name of columns in them. SELECT DISTINCT TABLE_NAME FROM INFORMATION_SCHEMA. COLUMNS WHERE COLUMN_NAME IN('column1', 'column2') AND TABLE_SCHEMA = 'schema_name';
SELECT table_name,table_schema FROM INFORMATION_SCHEMA.COLUMNS WHERE column_name='sort_method'
You can query the INFORMATION_SCHEMA.COLUMNS
system table:
SELECT COLUMN_NAME, TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'sort_method'
More information is in http://dev.mysql.com/doc/refman/5.0/en/columns-table.html.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With