Duplicate entry for key 'group_key'

前端 未结 3 971
北荒
北荒 2020-12-03 12:00

I\'m running a query in MySQL where I\'m grouping by four columns and selecting a lot of things, including the four values I\'m grouping by. But I get this error when I run

相关标签:
3条回答
  • 2020-12-03 12:25

    This is usually disk space issue. Specially temporary space (in linux /tmp). Check you database server Disk space.

    0 讨论(0)
  • 2020-12-03 12:32

    Your issue seems like a MySQL bug. I was reviewing the logs for our production server the other day and the error logs were filled with this error. I used the workaround below and the errors are gone.

    SET SESSION max_heap_table_size=536870912;

    SET SESSION tmp_table_size=536870912;

    Source: http://bugs.mysql.com/bug.php?id=58081

    0 讨论(0)
  • 2020-12-03 12:36

    You should put the aliases in the group buy like this:

    Create table table2 as
    Select round(x, 0) as x, round(a, 0) as a, round(b, 0) as b, c, d, e, f
    from table1
    group by x, a, b, c;
    
    0 讨论(0)
提交回复
热议问题