[Maria-discuss] [newbie] Include latest ID into INSERT?
23 Jan
2023
23 Jan
'23
4:58 a.m.
Hello, I need to write a script in SQL to import topics + posts into a phpBB forum. The issue I have is: How can I reference the last topic ID when adding a post to it, since a post must reference a topic? ============ #Create new topic (ie. discussion thread) INSERT INTO `phpbb_topics` (forum_id,topic_title,topic_poster,topic_time) VALUES (); #Add first post to topic #INSERT INTO `phpbb_posts` (topic_id,forum_id,poster_id,post_time,post_username,post_text) VALUES (); INSERT INTO `phpbb_posts` (SELECT LAST_INSERT_ID(),forum_id,poster_id,post_time,post_username,post_text) VALUES (); ============ Can it be done in SQL, or should I write it in eg. Python? Thank you.
698
Age (days ago)
698
Last active (days ago)
0 comments
1 participants
participants (1)
-
Gilles