INSERT WITH SELECT查询给我语法错误?

时间:2013-07-02 07:24:00

标签: android sql sqlite cordova

任何人都可以让我知道我在这里做错了什么.....   尝试在sqlite数据库管理器中运行查询时,这是我的查询并获得语法错误“near SELECT”

INSERT INTO proposal_products(proposal_id,date_created,date_modified,quantity,installation_position,notes,proposal_location_id,parent_id,prompt,cost_price,sale_price,service_price,labour_hours,maint_hours,comm_hours,adj_cost_price,adj_sale_price,adj_service_price,adj_labour_hours,adj_maint_hours,adj_comm_hours,is_adjusted,adj_unit_price,discipline_products_id)VALUES('1000000','27-02-2013','27-02-2013',3,'dfdf','dsdsd',6,58,'hghfg',21,22,22,48,45,45,0,0,0,0,0,0,1,0,SELECT id FROM discipline_products WHERE product_id = SELECT id FROM products WHERE c4w_code = 'STDD')

这是错误的快照 enter image description here

2 个答案:

答案 0 :(得分:0)

尝试这种方式:

INSERT INTO proposal_products(proposal_id,date_created,date_modified,quantity,installation_position,notes,proposal_location_id,parent_id,prompt,cost_price,sale_price,service_price,labour_hours,maint_hours,comm_hours,adj_cost_price,adj_sale_price,adj_service_price,adj_labour_hours,adj_maint_hours,adj_comm_hours,is_adjusted,adj_unit_price,discipline_products_id)
SELECT '1000000','27-02-2013','27-02-2013',3,'dfdf','dsdsd',6,58,'hghfg',21,22,22,48,45,45,0,0,0,0,0,0,1,0, id 
FROM discipline_products 
WHERE product_id = (SELECT id FROM products WHERE c4w_code = 'STDD')

答案 1 :(得分:0)

INSERT INTO proposal_products 
(
    proposal_id,
    date_created,
    date_modified,
    quantity,
    installation_position,
    notes,
    proposal_location_id,
    parent_id,
    prompt,
    cost_price,
    sale_price,
    service_price,
    labour_hours,
    maint_hours,
    comm_hours,
    adj_cost_price,
    adj_sale_price,
    adj_service_price,
    adj_labour_hours,
    adj_maint_hours,
    adj_comm_hours,
    is_adjusted,
    adj_unit_price,
    discipline_products_id
)
VALUES( '1000000',
        '27-02-2013',
        '27-02-2013',
        3,
        'dfdf',
        'dsdsd',
        6,
        58,
        'hghfg',
        21,
        22,
        22,
        48,
        45,
        45,
        0,
        0,
        0,
        0,
        0,
        0,
        1,
        0,
       ( SELECT id FROM discipline_products WHERE product_id = (SELECT id 
                                                                 FROM products
                                                                WHERE c4w_code = 'STDD')
        ))