Last active
November 5, 2018 16:20
-
-
Save kwstannard/0a2125a01f59f603ea4d30978b85764a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql> create temporary table tmp (d INT(11)); | |
Query OK, 0 rows affected (0.02 sec) | |
/* there are 2 rows being inserted with value of 1 */ | |
mysql> insert into tmp (d) values (1), (2), (1), (3); | |
Query OK, 4 rows affected (0.01 sec) | |
/* this shows that distinct works */ | |
mysql> select distinct d from tmp; | |
+------+ | |
| d | | |
+------+ | |
| 1 | | |
| 2 | | |
| 3 | | |
+------+ | |
3 rows in set (0.00 sec) | |
/* This shows that if a row becomes different then distinct operates off the row */ | |
mysql> select distinct d, RAND() as e from tmp; | |
+------+---------------------+ | |
| d | e | | |
+------+---------------------+ | |
| 1 | 0.8762416912952826 | | |
| 2 | 0.09092339043591487 | | |
| 1 | 0.8258919090273714 | | |
| 3 | 0.8566894045627578 | | |
+------+---------------------+ | |
4 rows in set (0.01 sec) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment