In the SQL statement, there is a table where the user has the id and u_id fields. if the data is inserted, the id value will automatically increase. Can the u_id obtain a random value? I am interested in learning. no one cares about it. Are you willing to help ?, No. ID. this is the auto-increment primary key. inserttablev SQL statement is incorrect.
There is a table in which the user has the id and u_id fields. if the data is inserted, the id value will automatically increase. Can the u_id also obtain a random value? I am interested in learning. no one cares about it. Are you willing to help?
------ Solution --------------------
No. ID. this is the auto-increment primary key.
------ Solution --------------------
Insert table values (null, rand ());
To obtain a random integer R in the range of I ≤ R ≤ j, use the expression FLOOR (I + RAND () * (j-I + 1 ))
------ Solution --------------------
When creating a database table:
SQL code
Create table 'user' ('id' int (6) not null AUTO_INCREMENT, 'U _ id' int (6) not null, primary key ('id ')) ENGINE = MyISAM AUTO_INCREMENT = 85 default charset = utf8 CHECKSUM = 1 DELAY_KEY_WRITE = 1 ROW_FORMAT = DYNAMIC
------ Solution --------------------
Insert values (null, rand ());
To obtain a random integer R in the range of I ≤ R ≤ j, use the expression FLOOR (I + RAND () * (j-I + 1 ))
------ Solution --------------------
Writing a stored procedure is good and flexible.
------ Solution --------------------
The auto_increment attribute increases automatically.
------ Solution --------------------
Discussion
No. ID. this is the auto-increment primary key.