I have this Statement:
INSERT INTO qa_costpriceslog (item_code, invoice_code, item_costprice)
VALUES (1, 2, (SELECT item_costprice FROM qa_items WHERE item_code = 1));
I’m trying to insert a value copy the same data of item_costprice, but show me the error:
Error Code: 1136. Column count doesn't match value count at row 1
How i can solve this?
Use numeric literals with aliases inside a
SELECTstatement. No()are necessary around theSELECTcomponent.Note that in context of an
INSERT INTO...SELECT, the aliases are not actually necessary and you can justSELECT 1, 2, item_costprice, but in a normalSELECTyou’ll need the aliases to access the columns returned.