你好我想从选择查询的列中插入值
insert into (cmts) stat_alert
values(SELECT stat_alert.cell,stat_alert.cmts,cell_cmt.cmts FROM stat_alert`LEFT OUTER JOIN cell_cmt ON cell_cmt.`cell`=stat_alert.cell WHERE stat_alert.`cell`=cell_cmt.cell )
我有语法错误谁能帮助我??
您不需要VALUES
关键字和圆括号:
INSERT INTO <table name> (<comma separated column list>)
SELECT <comma separated column list> FROM <table name>
你想使用INSERT INTO otherTable (cols) SELECT <yourColumns> FROM <yourtable>
not INSERT INTO ... VALUES()
:
insert into stat_alert (cmts) -- list your columns here to insert into
SELECT cell_cmt.cmts -- your values to be inserted are here
FROM stat_alert
LEFT OUTER JOIN cell_cmt
ON cell_cmt.`cell`=stat_alert.cell
WHERE stat_alert.`cell`=cell_cmt.cell
看起来你有:
values
此类查询中不需要关键字时的关键字。