哪位大哥帮我看看这句sql有什么错?
conn.execute "INSERT INTO sys_order_action (productid,offerno,brand,customer,qty,sale_price,cs_remark,pic,WEIGHT) SELECT productid,offerno,brand,customer,qty,sale_price,cs_remark,pic,WEIGHT FROM view_order_offer WHERE (id= "&ddid& ") "
作用是把表 view_order_offer 里id=ddid查询出的数据添加到sys_order_action表
------解决方案--------------------conn.execute "INSERT INTO sys_order_action (productid,offerno,brand,customer,qty,sale_price,cs_remark,pic,WEIGHT) SELECT productid,offerno,brand,customer,qty,sale_price,cs_remark,pic,WEIGHT FROM view_order_offer WHERE [id]= " & ddid & ") "
如ID为字符型:
conn.execute "INSERT INTO sys_order_action (productid,offerno,brand,customer,qty,sale_price,cs_remark,pic,WEIGHT) SELECT productid,offerno,brand,customer,qty,sale_price,cs_remark,pic,WEIGHT FROM view_order_offer WHERE [id]=‘ " & ddid & "’) "
------解决方案----------------------所有的字段名加[],如果ID是数字,参数两侧不需要加单引号,但是如果是字符型,参数两侧需要加单引号:
conn.execute "INSERT INTO sys_order_action ([productid],[offerno],[brand],[customer],[qty],[sale_price],[cs_remark],[pic],[WEIGHT]])
SELECT [productid],[offerno],[brand],[customer],[qty],[sale_price],[cs_remark],[pic],[WEIGHT]
FROM view_order_offer WHERE ([id]= " & ddid & ") "