I have this table structure:
TABLE test
id int(11) AUTO_INCREMENT
value1 text
value2 text
value3 int(11)
If I run this query:
SELECT value1,value2 FROM test WHERE value3=45
I'll get 2 rows as result.
I have this PHP code.
$stmt = $mysqli->prepare("INSERT INTO test (value1,value2) SELECT value1,value2 FROM test WHERE value3=45");
$stmt->execute();
$id = $stmt->insert_id;
$stmt->close();
echo $id;
The code will insert 2 rows because the selects gives 2 rows as result, right? But $id will only be the id of the first inserted row. How could I get the id of the following inserted row?