Skip to content

Instantly share code, notes, and snippets.

@maxout
Last active December 22, 2015 19:39
Show Gist options
  • Save maxout/6520520 to your computer and use it in GitHub Desktop.
Save maxout/6520520 to your computer and use it in GitHub Desktop.
Shopware: export and import s_user_debit Db-Table
-- --------------------------------------------------------
--
-- Create View in export-DB to get data by customernumber and export it to a tmp table into the import-DB
--
-- --------------------------------------------------------
DROP VIEW IF EXISTS `v_user_debit_by_customernumber`;
CREATE VIEW `v_user_debit_by_customernumber` AS select `s_user_billingaddress`.`customernumber` AS `customernumber`,`s_user_debit`.`account` AS `account`,`s_user_debit`.`bankcode` AS `bankcode`,`s_user_debit`.`bankname` AS `bankname`,`s_user_debit`.`bankholder` AS `bankholder` from (`s_user_billingaddress` join `s_user_debit`) where (`s_user_billingaddress`.`userID` = `s_user_debit`.`userID`);
-- --------------------------------------------------------
--
-- Insert Data from tmp-table into s_user_debit by matching the userID by customernumber
--
-- --------------------------------------------------------
INSERT INTO `s_user_debit` (`userID`,`account`,`bankcode`,`bankname`,`bankholder`)
SELECT
`s_user_billingaddress`.`userID`,
`s_user_debit_tmp`.`account`,
`s_user_debit_tmp`.`bankcode`,
`s_user_debit_tmp`.`bankname`,
`s_user_debit_tmp`.`bankholder`
FROM `s_user_billingaddress`, `s_user_debit_tmp`
WHERE `s_user_billingaddress`.`customernumber` = `s_user_debit_tmp`.`customernumber` COLLATE utf8_unicode_ci
-- --------------------------------------------------------
--
-- After all drop tmp table
--
-- --------------------------------------------------------
DROP TABLE `s_user_debit_tmp`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment