首先请理解,SQL目前不是我的强大领域之一,我有点不确定为什么我无法获得查询 - 做到这一点,这似乎是可能的。SQL插入?插入数据从一个到另一个
我们正在运行一个MySQL服务器V5.1
我有我需要插入一条记录转化为我们的客户列表的filenotes表。
所以我做到了。
insert into filenote(clientid, notetype, datetime, notedetails)
VALUES (clienttable.clientid, 'info','2011-09-29 09:00:00', 'example note')
select clienttable.clientid from clienttable
where clienttable.clientid in (1,2,3,4,5,6,7,8,9)
但我不断收到错误,从SQL与select语句,有错误的问题是什么,虽然没有任何迹象表明,它只是规定。
“你有你的SQL语法附近选择clienttable.clientid 从clienttable一个错误的位置clienttable.clientid在(”
虽然我知道有一个问题,在那里,我什么也看不见这个问题会。请注意,字段名不表中匹配。
这是我遵循的例子。
INSERT INTO Store_Information (store_name, Sales, Date)
SELECT store_name, Sales, Date
FROM Sales_Information
WHERE Year(Date) = 1998
你们是不是在同一个SQL脚本来执行这两句?如果是这样,你需要在每个分支的末尾添加一个分号(或分别启动它们)。 – m0skit0