我遇到一个很奇怪的问题。我确信我在这行代码中没有做错任何事:
INSERT INTO
oc_address
(`cust_id`, `firstname`, `lastname`, `address_1`, `city`, `postcode`, `country_id`)
SELECT
(`cust_id`, `first_name`, `last_name`, `address`, `city`, `postalcode`, `country`)
FROM old_customer;
我仍然得到消息"#1241 -操作数应该包含1列"
有没有人看到我没看到的东西?我想这可能是由address_1的_1引起的。但为什么会…我希望有别的解释删除SELECT
语句中( )
周围的列,
INSERT INTO oc_address (cust_id, firstname, lastname, address_1, city, postcode, country_id)
SELECT cust_id, first_name, last_name, address, city, postalcode, country
FROM old_customer;
- SQLFiddle Demo (包含两个语句)
删除列名称中的'
符号和SELECT
中的()
符号。
INSERT INTO
oc_address
(cust_id, firstname, lastname, address_1, city, postcode,country_id)
SELECT
cust_id, first_name, last_name, address, city, postalcode, country
FROM old_customer;