mysql> select floor(rand(1)*2) a from information_schema.tables group by a having count(*)>1;
+---+
| a |
+---+
| 0 |
| 1 |
+---+
2 rows in set (0.00 sec)mysql> select floor(rand(0)*2) a from information_schema.tables group by a having count(*)>1;
ERROR 1062 (23000): Duplicate entry '1' for key 'group_key'这两个sql语句就rand()的种子数0,1 不一样,为啥会出现这种情况
+---+
| a |
+---+
| 0 |
| 1 |
+---+
2 rows in set (0.00 sec)mysql> select floor(rand(0)*2) a from information_schema.tables group by a having count(*)>1;
ERROR 1062 (23000): Duplicate entry '1' for key 'group_key'这两个sql语句就rand()的种子数0,1 不一样,为啥会出现这种情况
mysql 5.1.32下测试没有问题
SELECT FLOOR(RAND(0)*2) a FROM information_schema.TABLES) a1 GROUP BY a HAVING COUNT(*)>1;;
mysql 5.1.32下测试没有问题
http://bugs.mysql.com/bug.php?id=32249