i have tables that looks like this :
================================= ==========================
USER NOTE
================================= ==========================
id_u int auto_increment (PK) id_n int auto_increment (PK)
name varchar(50) id_u int (FK)
text varchar(100)
================================= ==========================
I am curious if this query might cause any problems on a website with a large amount of users.
$query = "INSERT INTO USER VALUES('','john')"; //query
$result = mysql_query($query);
if($result){
$query = "INSERT INTO NOTE VALUES (LAST_INSERT_ID(),'','abc')";
$result = mysql_query($query);
if($result){
echo "success";
}else{
echo "failed";
}
}else{
echo "failed";
}
Will it be fine if multiple users use this query at the same time?
When selecting from and inserting into a table at the same time, MySQL creates a temporary table to hold the rows from the SELECT and then inserts those rows into the target table. However, it remains true that you cannot use INSERT INTO t ... SELECT ... FROM t when t is a TEMPORARY table, because TEMPORARY tables cannot be referred to twice in the same statement
reference : http://dev.mysql.com/doc/refman/5.7/en/insert-select.html