A quick tip – I kind of have the feeling that I’ve covered this before, but whatever – well, just the simple SQL query below will do:
CREATE TABLE temp SELECT id, COUNT(id) FROM `book` GROUP BY isbn, subject HAVING COUNT(id) > 1
Wherein each combination of column isbn and column subject in each of the rows from table book should be unique and you want to find out those duplicate ones. You can simply select without creating a temporary table to store the duplicates, but this would come handy when the book table has like 1 million records.
To do more by not just finding duplicate records but also extracting the unique ones, read this.
Related Posts
- MySQL: Counting Number of Records or Rows by a Foreign Column (from Another Table)
- MySQL: Deleting Duplicate Rows or Records | Selecting Unique Rows into A New Table
- MySQL: Add Statistics Column for the Number Count of Records from Another Table
- Using SQL to Find records existing in one table but not in another
- MySQL: Update Multiple Rows or Records with One Single Query
