gpt4 book ai didi

mysql - 数据迁移脚本 INSERT INTO

转载 作者:太空宇宙 更新时间:2023-11-03 12:32:42 26 4
gpt4 key购买 nike

我创建了以下 SQL 代码来迁移我们的数据库。 UP 查询工作正常,但我不知道如何修复 DOWN 查询。我只想插入 payment_gateway 表中的所有数据,但还必须匹配正确的 reseller_shop.id。

// UP
INSERT INTO payment_gateway (`type`, account, keyIn, keyOut, resellerShopId)
SELECT 'paymentGatewayOgone', rs.ogoneAccount, rs.ogoneSignatureIn, rs.ogoneSignatureOut, rs.id
FROM reseller_shop AS rs
WHERE rs.ogoneAccount <> '';

// DOWN
INSERT INTO reseller_shop (ogoneAccount, ogoneSignatureIn, ogoneSignatureOut)
SELECT pg.account, pg.keyIn, pg.keyOut
FROM payment_gateway AS pg
WHERE pg.type = 'paymentGatewayOgone'
AND reseller_shop.id = pg.resellerShopId

最佳答案

INSERT INTO reseller_shop (ogoneAccount, ogoneSignatureIn, ogoneSignatureOut)
SELECT pg.account, pg.keyIn, pg.keyOut FROM payment_gateway AS pg
WHERE pg.type = 'paymentGatewayOgone' AND pg.resellerShopId in
(select reseller_shop.id from reseller_shop_id)

希望对你有帮助

关于mysql - 数据迁移脚本 INSERT INTO,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14624954/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com