0

I'm having a verry strange problem. I am certain I have done nothing wrong in this line of code:

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;

Still I get the message "#1241 - Operand should contain 1 column(s)"

Does anybony see something I don't see? I was thinking it may be caused by the _1 at address_1. But why would that be... I hope there is another explanation

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828

2 Answers2

3

Remove the ' symbols for your column names and the () in your 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;
phadaphunk
  • 12,785
  • 15
  • 73
  • 107
3

remove ( ) around the columns on SELECT ststement,

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;
John Woo
  • 258,903
  • 69
  • 498
  • 492