Example) member_table
no - auto increment,
id - not null,
pw - not null,
email,
phone,
address
$sql1= "INSERT INTO member_table (no ,id, pw, email,phone,address) VALUES (NULL, '$id', '$pw', '$email', '$phone', '$address')";
$sql2 = "INSERT INTO member_table (no ,id, pw, email,phone,address) VALUES ('', '$id', '$pw', '$email', '$phone', '$address')";
$sql3 = "INSERT INTO member_table (id, pw, email,phone,address) VALUES ('$id', '$pw', '$email', '$phone', '$address')";
If you put data in the member_table above, as shown in $sql1 and $sql2, you can write NULL in the auto_increment column, no, or you can write it by adding a sink quota. What is the difference between the two?
And one more question, is there any difference from just using it with $sql3?
Please answer me.
mysql insert auto_increment
MySQL automatically assigns a sequence number if you do not assign a value for the auto_increment column or if you assign a zero. Also, if the auto_increment column is NOT NULL, the sequence number is assigned even if NULL is assigned.
If you look at the case of the member_table above,
INSERT INTO member_table
(id, pw, email, phone, address)
VALUES (1, 'password', '[email protected]', '010-1111-1111', 'address');
INSERT INTO member_table
(no, id, pw, email, phone, address)
VALUES (0,1, 'password', '[email protected]', '010-1111-1111', 'address');
INSERT INTO member_table
(no, id, pw, email, phone, address)
VALUES (NULL, 1, 'password', '[email protected]', '010-1111-1111', 'address');
If you put '' (blank) in the case you mentioned, an error will occur that it is not an integer value. In general, it seems that many people do not assign values to the auto_increment column.
888 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
610 Uncaught (inpromise) Error on Electron: An object could not be cloned
600 GDB gets version error when attempting to debug with the Presense SDK (IDE)
567 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.