我已经使用如下所列的代码将一些客户端从一个SQL合并到另一个SQL(209个客户端):
INSERT INTO `tblclients` (`firstname`, `lastname`, `companyname`, `email`, `address1`, `address2`, `city`, `state`, `postcode`, `country`, `phonenumber`, `password`, `currency`, `defaultgateway`, `credit`, `taxexempt`, `latefeeoveride`, `overideduenotices`, `separateinvoices`, `disableautocc`, `datecreated`, `notes`, `billingcid`, `securityqid`, `securityqans`, `groupid`, `cardtype`, `cardlastfour`, `cardnum`, `startdate`, `expdate`, `issuenumber`, `bankname`, `banktype`, `bankcode`, `bankacct`, `gatewayid`, `lastlogin`, `ip`, `host`, `status`, `language`, `pwresetkey`, `pwresetexpiry`) VALUES
('Name', 'LastName', 'companyname', 'gdfgdfg@example.no', 'Gatenavn 6', '', 'Halden', 'Østfold', '1780', 'NO', '+4452335445', '339bfb3999994f0e7c696c7cafafbbe:U#!!I', 1, '', '0.00', 'on', 'on', 'on', '', '', '2011-05-11', '', 0, 0, 'YAiAIpIrK5KcghdhdfgdfFGDF/jWZd7654564A==', 1, '', '', '', '', '', '', '', '', '', '', '', '2011-12-31 01:20:43', '81.000.00.000', '81.000.00.000', 'Active', '', '', 0),
('Name2', 'LastName', 'companyname', 'gdfgdfg@example.no', 'Nilsen 154', '', 'Fredrikstad', 'Østfold', '1904', 'NO', '+445244535445', '339bfb36654f0e7c696c7cafafbbe:U#!!I', 1, '', '0.00', 'on', 'on', 'on', '', '', '2011-05-11', '', 0, 0, 'YAiAIpIrK5KcghdhdfgdfFG56465DF/jWZd7A==', 2, '', '', '', '', '', '', '', '', '', '', '', '2011-12-31 01:20:43', '81.000.00.000', '81.000.00.000', 'Active', '', '', 0),
('Cliff', 'LastName', 'companyname', 'gdfgdfg@example.no', 'Josefineveri 2', '', 'Oslo', 'Østfold', '4544', 'NO', '+445244, '339bfb35556330e7c696c7cafafbbe:U#!!I', 1, '', '0.00', 'on', 'on', 'on', '', '', '2011-05-11', '', 0, 0, 'YAiAIpIrK5KcghdhdfgdfFGDF/jWZd74546A==', 3, '', '', '', '', '', '', '', '', '', '', '', '2011-12-31 01:20:43', '81.000.00.000', '81.000.00.000', 'Active', '', '', 0),
('Ann', 'LastName', 'companyname', 'gdfgdfg@example.no', 'oskar 183', '', 'Hamar', 'Østfold', '0001', '5158', '+44524445445', '339bfb6644f0e7c696c7cafafbbe:U#!!I', 1, '', '0.00', 'on', 'on', 'on', '', '', '2011-05-11', '', 0, 0, 'YAiAIpIrK5KcghdhdfgdfFGDF/jWZd755A==', 2, '', '', '', '', '', '', '', '', '', '', '', '2011-12-31 01:20:43', '81.000.00.000', '81.000.00.000', 'Active', '', '', 0),
如何在列出的所有分组上将groupid
更改为5,而不是未列出的分区?我之前有500个客户,不应该得到新的groupid
。
客户端是导入的,所以也许我可以使用SQL WHERE或其他东西来做它?
解决方案:我知道导入之前的最新ID。所以我刚刚做了:
UPDATE `norskhos_nhnfm`.`tblclients`
SET `groupip` = '5'
WHERE `tblclients`.`id` >= 571;
答案 0 :(得分:0)
我有点困惑"在列出的所有分组上将groupid更改为5,但不是未列出的分组?"
如果我理解正确...在SQL Server中(我相信你没有使用,但类似)我会这样做:
假设电子邮件是唯一的
UPDATE `norskhos_nhnfm`.`tblclients`
SET `groupip` = '5'
WHERE `tblclients`.`id` >= 571;
AND email not in(not them that is not listed)