你好我想在选择查询的列中插入值
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 )
我有语法错误 谁能帮助我?
答案 0 :(得分:3)
您不需要VALUES
关键字和圆括号:
INSERT INTO <table name> (<comma separated column list>)
SELECT <comma separated column list> FROM <table name>
答案 1 :(得分:1)
您想使用INSERT INTO otherTable (cols) SELECT <yourColumns> FROM <yourtable>
而不是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
答案 2 :(得分:0)
看起来你有:
values
个关键字。