1

我使用下面列出的代码将一些客户端从一个 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在列出的所有 clent 上更改为 5,而不是在未列出的 clent 上更改为 5?我之前有 500 个客户,不应该是新的groupid。客户端是导入的,所以也许我可以使用 SQL WHERE 或其他东西来做它?

解决方案:我知道导入前的最新 ID。所以我只是做了:

 UPDATE `norskhos_nhnfm`.`tblclients`
 SET `groupip` = '5'
 WHERE `tblclients`.`id` >= 571;
4

1 回答 1

0

我对“在列出的所有 clents 上将 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)
于 2014-09-04T23:42:42.190 回答