update cargotype ct set ct.Pid =
(
select c.CargoTypeId as Pid
from cargoinfo c, cargotype t
where t.TypeName = c.Sku and t.Pid = 42 and c.CargoTypeId <> 42
and ct.CargoTypeId = t.CargoTypeId
)
总报
[Err] 1093 - You can't specify target table 'ct' for update in FROM clause网上找了很大说是要弄个临时表或者再套子查询,都试了不行。
是不是要弄程序才能完成用子查询的记录来更新的目的SQLmysql
解决方案 »
- 求大神帮找下linux下的mysql4.0.20升级到mysql4.0.25补丁,缓冲区漏洞问题,急需补丁
- MySQL存储过程中如何保存select count(*)的结果为整数
- java中如何读取Mysql中的时间字段使它与表中的数据完全一致
- 关于MYSQL排序问题
- Mysql_5.0.24a安装后中文显示“???”问题
- 如何解决这个问题?
- 各位兄弟姐妹们快进来帮帮小弟的忙,说来问题也很怪,在百度上都收索不到关键词!我想起了csdn这里的高手多!
- 请问:现在成熟的开放源代码数据库有哪些?
- 高手教育下如何查询这个表
- 求助!!MySQL空间问题!!高分(前面两个出错)
- 求大神优化sql
- 菜鸟,请教SQL语句
update cargotype ct INNER JOIN cargoinfo c
ON
Ct.TypeName = c.Sku and Ct.Pid = 42 and c.CargoTypeId <> 42
set ct.Pid = c.CargoTypeId
select t.CargoTypeId,c.CargoTypeId as Pid
from cargoinfo c, cargotype t
where t.TypeName = c.Sku and t.Pid = 42 and c.CargoTypeId <> 42
) x
set ct.Pid = x.Pid
where ct.CargoTypeId = x.CargoTypeId
set t.pid=c.CargoTypeId
from cargoinfo c, cargotype t
where t.TypeName = c.Sku and t.Pid = 42 and c.CargoTypeId <> 42
and ct.CargoTypeId = t.CargoTypeId