as you know LAST_INSERT_ID()
for AUTO_INCREMENT
ed column's inserted value.and NULL
for AUTO_INCREMENT
forces generating new value. what if you use NULL rather than last_insert_id():
INSERT INTO A
SELECT NULL, B.id,C.name,C.address,
FROM sample_table C JOIN other_table B ON B.phoneNumber=C.phoneNumber;
Is there any reason you must use last_insert_id()? or just question?