mercredi 30 octobre 2019

Creating sequences in MySQL?

I saw in articles that can we use functions rand() and floor() to create a sequences from 0 and 1

mysql

SELECT floor(rand(0)*2) FROM security.users;

+------------------+
| floor(rand(0)*2) |
+------------------+
|                0 |
|                1 |
|                1 |
|                0 |
|                1 |
|                1 |
|                0 |
|                0 |
|                1 |
|                1 |
|                1 |
|                0 |
|                1 |
|                1 |
|                1 |
|                0 |
+------------------+
16 rows in set (0.00 sec)

is there any another way to achieve this ?
* i dont talk about auto_increment ;




Aucun commentaire:

Enregistrer un commentaire