国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

In mysql, when writing data, do you need to write the data first and then give the data an id? Or should you give the id first and then write the data to be inserted?
伊謝爾倫
伊謝爾倫 2017-05-18 10:51:19
0
2
667

Mysql has an automatically growing id. Now if you write a piece of data into it, the specific process is whether to write the data first and then give the data an id, or give the id first and then insert it. Write the data into
. Just curious

伊謝爾倫
伊謝爾倫

小伙看你根骨奇佳,潛力無限,來學(xué)PHP伐。

reply all(2)
過去多啦不再A夢(mèng)

MYSQL has already calculated the auto-increment ID that needs to be filled in next time

As shown in the picture below. The database has 62 rows, and the value has increased to 63.

If the ID is not specified, MYSQL will fill it in by itself. If the filling is less than the automatic increment, an error will be reported! If the filling is greater than the automatic increment, the automatic increment will become the filling number + 1

Get insert ID:
MYSQLI: mysqli_insert_id method
PDO: PDO::lastInsertId method
MYSQL: mysql_insert_id method

The MYSQL method of connecting to the database has been deprecated and may be removed in future versions

The SQL below can achieve what you want, but I’m not sure if it’s a good idea. Also, is it really good to set the data structure like this?

INSERT INTO sta_log_fun(`FCNAME`,`STATUS`) VALUES('WOQU',(SELECT auto_increment FROM information_schema.`TABLES` WHERE TABLE_SCHEMA='test2' AND TABLE_NAME='sta_log_fun'));

The effect is as shown below:

洪濤

I haven’t researched it, but I guess it’s the same as when we manually insert data, it’s written together. Get the maximum value of the current table id, add the set auto-increment value, and insert the data together. . . .

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template