INSERT INTO with SubQuery MySQL

前端 未结 5 1159
無奈伤痛
無奈伤痛 2020-12-02 19:39

I have this Statement:

INSERT INTO qa_costpriceslog (item_code, invoice_code, item_costprice)
    VALUES (1, 2, (SELECT item_costprice FROM qa_items WHERE it         


        
5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-02 20:30

    Your insert statement contains too many columns on the left-hand side or not enough columns on the right hand side. The part before the VALUES has 7 columns listed, but the second part after VALUES only has 3 columns returned: 1, 2, then the sub-query only returns 1 column.

    EDIT: Well, it did before someone modified the query....

提交回复
热议问题