以下语句在SQL Server 2008里执行是正确的,在MySQL里执行错误,
我对MySQL不熟悉,请大家指教指教!update goods_combine set sn = T.minID
from (select min(id) minID, sn from goods_combine group by sn)T
where goods_combine.sn = T.sn在MySQL里执行错误:
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from (select min(id) minID, sn from goods_combine group by sn)T
where goods_com' at line 2
表结构:
CREATE TABLE `goods_combine`
(
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT '".iconv("gbk","utf-8","联合ID")."',
sn VARCHAR(64) NOT NULL COMMENT '".iconv("gbk","utf-8","序号(联合编号)")."',
goods_id INT NOT NULL COMMENT '".iconv("gbk","utf-8","实物ID")."'
)
我对MySQL不熟悉,请大家指教指教!update goods_combine set sn = T.minID
from (select min(id) minID, sn from goods_combine group by sn)T
where goods_combine.sn = T.sn在MySQL里执行错误:
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from (select min(id) minID, sn from goods_combine group by sn)T
where goods_com' at line 2
表结构:
CREATE TABLE `goods_combine`
(
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT '".iconv("gbk","utf-8","联合ID")."',
sn VARCHAR(64) NOT NULL COMMENT '".iconv("gbk","utf-8","序号(联合编号)")."',
goods_id INT NOT NULL COMMENT '".iconv("gbk","utf-8","实物ID")."'
)
解决方案 »
- 有高并发写数据库的需求,求知道
- 关于mysql cluster中NDB表的问题
- 这个是什么原因啊,哪位大侠给我看看!!!
- 求SQL~~~~~~~~~~~~
- 我用mysql创建的存储过程有错误,大家帮我看一下
- 高手救命了,MySQL重装时原数据库未备份,现在只有原来的data文件夹内容,怎样把数据库恢复
- unixODBC 和 MyODBC 之间的关系是什么?
- VB 与MySQL数据库的大部问题
- shell>提示符是如何出现的?
- 表存在,表数据文件也存在,报ERROR 1146 (42S02): Table 'xxx.xxx' doesn't exist
- mysql语句难题 请高手指教
- java程序备份postgresql 怎么调用?
inner join
(select min(id) minID, sn from goods_combine group by sn) T
on goods_combine.sn = T.sn
set sn = T.minID
update goods_combine inner join
(select min(id) minID, sn from goods_combine group by sn) T
on goods_combine.sn = T.sn
set goods_combine.sn = T.minID