Remove Duplicate record from Mysql Table using Group By

Nick

I have a table structure and data below. enter image description here

I need to remove duplicate record from the table list. My confusion is that when I am firing query

SELECT * FROM `table` GROUP BY CONCAT(`name`,department)

then giving me correct list(12 records).

enter image description here

Same query when I am using the subquery:

SELECT * 
FROM `table` WHERE id IN (SELECT id FROM `table` GROUP BY CONCAT(`name`,department))  

It returning all record which is wrong.

Table Structure

So, My question is why group by in subquery is not woking.

Zafar Malik

Actually as Tim mentioned in his answer that it to get first unique record by group by clause is not a standard feature of sql but mysql allows it till mysql5.6.16 version but from 5.6.21 it has been changed.

Just change mysql version in your sql fiddle and check that you will get what you want.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

select latest duplicate record from table MySQL

From Dev

Mysql remove duplicate entries from table

From Dev

Remove Duplicate Record from XML file using XLST

From Dev

How to select the lastest record from a group in MySQL table using SQl syntax

From Dev

Remove duplicate rows from MySQL table (ignore chars and whitespace)

From Dev

how to select latest record from table by using Group by statements

From Dev

Using group by to get most recent record from table

From Dev

how to select latest record from table by using Group by statements

From Dev

Remove duplicate rows from Html Table using jquery

From Dev

Remove duplicate rows from Html Table using jquery

From Dev

How to remove duplicate record using linq?

From Dev

sql remove duplicate record while using join

From Dev

sql remove duplicate record while using join

From Dev

How to remove duplicate record using linq?

From Dev

How to remove duplicate records by taking last record in each group

From Dev

Remove duplicate rows on many to many table (Mysql)

From Dev

Remove duplicate rows on many to many table (Mysql)

From Dev

MySQL latest record from table

From Dev

How remove from group in table

From Dev

Teradata bteq sql to remove duplicate record with min(column) in table

From Dev

How to remove duplicate records from the table

From Dev

SQL - Remove Duplicate Rows From Table

From Dev

Remove duplicate records from database table

From Dev

MYSQL: Retrievieng the last record from each group and combining with the data of another table

From Dev

mysql multiple record set from group by

From Dev

How can I remove a duplicate record from the list and mark it with an enum?

From Dev

Delete 2nd Duplicate Record in mySql Table

From Dev

Using GROUP BY in MySQL Join Table

From Dev

SQL-Using unique constraints to remove duplicate entries from being entered in a table

Related Related

  1. 1

    select latest duplicate record from table MySQL

  2. 2

    Mysql remove duplicate entries from table

  3. 3

    Remove Duplicate Record from XML file using XLST

  4. 4

    How to select the lastest record from a group in MySQL table using SQl syntax

  5. 5

    Remove duplicate rows from MySQL table (ignore chars and whitespace)

  6. 6

    how to select latest record from table by using Group by statements

  7. 7

    Using group by to get most recent record from table

  8. 8

    how to select latest record from table by using Group by statements

  9. 9

    Remove duplicate rows from Html Table using jquery

  10. 10

    Remove duplicate rows from Html Table using jquery

  11. 11

    How to remove duplicate record using linq?

  12. 12

    sql remove duplicate record while using join

  13. 13

    sql remove duplicate record while using join

  14. 14

    How to remove duplicate record using linq?

  15. 15

    How to remove duplicate records by taking last record in each group

  16. 16

    Remove duplicate rows on many to many table (Mysql)

  17. 17

    Remove duplicate rows on many to many table (Mysql)

  18. 18

    MySQL latest record from table

  19. 19

    How remove from group in table

  20. 20

    Teradata bteq sql to remove duplicate record with min(column) in table

  21. 21

    How to remove duplicate records from the table

  22. 22

    SQL - Remove Duplicate Rows From Table

  23. 23

    Remove duplicate records from database table

  24. 24

    MYSQL: Retrievieng the last record from each group and combining with the data of another table

  25. 25

    mysql multiple record set from group by

  26. 26

    How can I remove a duplicate record from the list and mark it with an enum?

  27. 27

    Delete 2nd Duplicate Record in mySql Table

  28. 28

    Using GROUP BY in MySQL Join Table

  29. 29

    SQL-Using unique constraints to remove duplicate entries from being entered in a table

HotTag

Archive