SQL query to find duplicate rows, in any table in Mysql database -
i'm looking schema-independent query. query should equally capable of catching duplicate rows in either table in database.i have number of tables without primary key. have found result sql server [which have experience] looking same thing in mysql
use dynamic sql generate query using column information in information_schema:
set @tablename = 'yourtable'; set @sql = ( select concat('select * `', table_name, '` group ', group_concat(concat('`', column_name, '`')), ' having count(*) > 1') information_schema.columns table_name = @tablename ); prepare stmt @sql; execute stmt;
Comments
Post a Comment