1/14/2024 0 Comments Mysql insert![]() I do not have it using transactions yet, since I still have yet to learn that. This is just simplified out from the original perl/dbi code, which does some logic to check each statement for failure. INSERT INTO main (id, title, added_on, date) SELECT id, title, added_on, date FROM stacks_tmp ĭELETE FROM main_date WHERE (id) IN (SELECT id FROM stacks_tmp WHERE from_table = 'date') ĭELETE FROM main_weekday WHERE (id) IN (SELECT id FROM stacks_tmp WHERE from_table = 'weekday') SELECT COUNT(*) FROM stacks_tmp ORDER BY date No temp table is needed and IO will be limited on tempdb.įor those curious, this is how I solved it, thanks to tip: LOCK TABLESĬREATE TEMPORARY TABLE IF NOT EXISTS stacks_tmp AS ( $sql_stacks_ready ) It simply inserts somewhere else the output of what has just been deleted. OUTPUT deleted.id, deleted.name, deleted.level INTO table2
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |