All pastes #391458 Raw Edit

Someone

public text v1 · immutable
·published 2007-03-12 04:31 UTC
rendered paste body
DECLARE @last_insert_id type INT;
DECLARE @pd_workout_id type INT;

SET @pd_workout_id = 3;

INSERT INTO workouts (time_start, length, comments, user_id) SELECT time_start, length, comments, user_id FROM pd_workouts AS pd WHERE id = @pd_workout_id;
	
select @last_insert_id := last_insert_id();

INSERT INTO cardio_sets (@last_insert_id, cardio_exercise_id, length) SELECT pd_workout_id, cardio_exercise_id, length FROM pd_cardio_sets  WHERE pd_workout_id = @pd_workout_id;

INSERT INTO weight_sets (@last_insert_id, weight_exercise_id, reps, weight) SELECT pd_workout_id, weight_exercise_id, reps, weight FROM pd_weight_sets  WHERE pd_workout_id = @pd_workout_id;