我有两张桌子(User.find(1).update_with_password(email: 'asdf@email.com', current_password: 'currentpass')
& RegisteredTBL
)。当用户注册学生时,所有值都将转到EnrolledTBL
,之后它将使用户能够支付学费以注册学生。
支付后(无论是全额付款还是分期付款),我想要的是删除RegisteredTBL
中插入的行并将其移至RegisteredTBL
。我该怎么做?我只需要mysql代码就如何做到这一点。
我想我可以将它应用于C#。请帮助。
答案 0 :(得分:1)
考虑两个表都包含具有相同数据类型和大小的字段。
插入操作
INSERT INTO EnrolledTBL
SELECT Field1,Field2,Field3,...
FROM RegisteredTBL
WHERE RegisteredTBL_ID = "your id";
删除操作
Delete from RegisteredTBL where RegisteredTBL_ID="your ID";
//RegisteredTBL_ID is your ID column