id, member_id, category, fixed, base_unit, base_amount, daily, weekly, monthly, yearly, `year`, `month`, created_at, updated_at INSERT INTO budget (member_id, category, fixed, base_unit, base_amount, daily, weekly, monthly, yearly, `year`, `month`, created_at, updated_at) VALUES (#{memberId}, #{category}, #{fixed}, #{baseUnit}, #{baseAmount}, #{daily}, #{weekly}, #{monthly}, #{yearly}, #{year}, #{month}, NOW(), NOW()) INSERT INTO budget (member_id, category, fixed, base_unit, base_amount, daily, weekly, monthly, yearly, `year`, `month`, created_at, updated_at) SELECT member_id, category, fixed, base_unit, base_amount, daily, weekly, monthly, yearly, #{toYear}, #{toMonth}, NOW(), NOW() FROM budget WHERE member_id = #{memberId} AND `year` = #{fromYear} AND `month` = #{fromMonth} ON DUPLICATE KEY UPDATE fixed = VALUES(fixed), base_unit = VALUES(base_unit), base_amount = VALUES(base_amount), daily = VALUES(daily), weekly = VALUES(weekly), monthly = VALUES(monthly), yearly = VALUES(yearly), updated_at = NOW() UPDATE budget SET category = #{category}, fixed = #{fixed}, base_unit = #{baseUnit}, base_amount = #{baseAmount}, daily = #{daily}, weekly = #{weekly}, monthly = #{monthly}, yearly = #{yearly} WHERE id = #{id} AND member_id = #{memberId} DELETE FROM budget WHERE id = #{id} AND member_id = #{memberId} UPDATE budget SET category = #{newName} WHERE member_id = #{memberId} AND category = #{oldName}