当前位置: 首页 > news >正文

学家装设计师要多少钱哈尔滨seo关键字优化

学家装设计师要多少钱,哈尔滨seo关键字优化,国家市场监督管理总局局长什么级别,深圳网站建设制作优化文章目录 一、发现问题二、场景1:在where条件中查询了修改表的数据三、场景2:在set语句中查询了修改表的数据 一、发现问题 在一次准备处理历史数据sql时,出现这么一个问题:You cant specify target table 表名 for update in FR…

文章目录

  • 一、发现问题
  • 二、场景1:在where条件中查询了修改表的数据
  • 三、场景2:在set语句中查询了修改表的数据

一、发现问题

在一次准备处理历史数据sql时,出现这么一个问题:You can't specify target table '表名' for update in FROM clause,大致的意思就是:不能在同一张表中先select再update。

在此进行一下复盘沉淀,使用测试sql复现当时的场景(mysql是8版本),准备测试数据:

CREATE TABLE `student` (`id` int NOT NULL,`name` varchar(255) DEFAULT NULL,`address` varchar(255) DEFAULT NULL,PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;INSERT INTO `athena_opencourse`.`student`(`id`, `name`, `address`) VALUES (1, '张三', '北京');
INSERT INTO `athena_opencourse`.`student`(`id`, `name`, `address`) VALUES (2, '李四', '上海');

二、场景1:在where条件中查询了修改表的数据

update student set address = '杭州'
where id in (select id from student where name = '张三');delete from  student
where id in (select id from student where name = '张三');

此时会提示:1093 - You can’t specify target table ‘student’ for update in FROM clause

解决方式:在where子句中再加一层,使其成为临时表:

update student set address = '杭州'
where id in (select tmp.id from (select id from student where name = '张三') tmp);

三、场景2:在set语句中查询了修改表的数据

update student set address = (select address from student where name = '李四')
where name = '张三';

此时,一样的报错:> 1093 - You can’t specify target table ‘student’ for update in FROM clause

解决方式同上,查询时再加一层,使其成为临时表:

update student set address = (select tmp.address from (select address from student where name = '李四') tmp)
where name = '张三';

或者使用update join的方案:

update student s1 ,student s2 
set s1.address = s2.address
where s1.name = '张三' and s2.name = '李四';

惊呆了有木有!使用update join语法,可以很轻松的实现跨表的数据修改。

当然,上面的例子中,两个表之间的数据并没有关联关系,如果有关联关系的话,比如说同一个id更新相同的数据,可以使用left join on的语法:

update student s1 
left join student s2 on s1.id = s2.id
set s1.address = s2.name;


文章转载自:
http://metopon.c7624.cn
http://scotophilic.c7624.cn
http://muslin.c7624.cn
http://faeces.c7624.cn
http://witling.c7624.cn
http://misandry.c7624.cn
http://sempervirent.c7624.cn
http://curarize.c7624.cn
http://haematinic.c7624.cn
http://ammonolysis.c7624.cn
http://spadework.c7624.cn
http://tsingtao.c7624.cn
http://kokura.c7624.cn
http://phototactic.c7624.cn
http://delphinine.c7624.cn
http://tradeoff.c7624.cn
http://aftermarket.c7624.cn
http://piscina.c7624.cn
http://sericin.c7624.cn
http://scrutineer.c7624.cn
http://macrosporangium.c7624.cn
http://celestite.c7624.cn
http://loath.c7624.cn
http://advertizement.c7624.cn
http://ramequin.c7624.cn
http://microzyme.c7624.cn
http://piny.c7624.cn
http://sub.c7624.cn
http://ineligibility.c7624.cn
http://soavemente.c7624.cn
http://cockswain.c7624.cn
http://brakeman.c7624.cn
http://crystallogeny.c7624.cn
http://aeneas.c7624.cn
http://nun.c7624.cn
http://wollaston.c7624.cn
http://catacomb.c7624.cn
http://giblets.c7624.cn
http://heatproof.c7624.cn
http://basilect.c7624.cn
http://alsatia.c7624.cn
http://majorca.c7624.cn
http://permit.c7624.cn
http://kinema.c7624.cn
http://minicamera.c7624.cn
http://inconvertible.c7624.cn
http://wakefield.c7624.cn
http://epicrisis.c7624.cn
http://telemedicine.c7624.cn
http://solely.c7624.cn
http://macrodont.c7624.cn
http://immerge.c7624.cn
http://piccolo.c7624.cn
http://symmography.c7624.cn
http://pilsener.c7624.cn
http://onlooker.c7624.cn
http://bogged.c7624.cn
http://lichenification.c7624.cn
http://lymphokine.c7624.cn
http://brunet.c7624.cn
http://tufty.c7624.cn
http://softhead.c7624.cn
http://telebanking.c7624.cn
http://osculate.c7624.cn
http://effluent.c7624.cn
http://veritably.c7624.cn
http://astucious.c7624.cn
http://hsf.c7624.cn
http://contemptuously.c7624.cn
http://tribunary.c7624.cn
http://ameroenglish.c7624.cn
http://fabled.c7624.cn
http://annals.c7624.cn
http://lepromatous.c7624.cn
http://refining.c7624.cn
http://unregarded.c7624.cn
http://ditch.c7624.cn
http://cosmical.c7624.cn
http://silky.c7624.cn
http://lpi.c7624.cn
http://fomes.c7624.cn
http://sopranino.c7624.cn
http://archwise.c7624.cn
http://lapwing.c7624.cn
http://interclavicular.c7624.cn
http://gemmaceous.c7624.cn
http://orthopraxis.c7624.cn
http://electrostriction.c7624.cn
http://queasiness.c7624.cn
http://trinitrobenzene.c7624.cn
http://swimsuit.c7624.cn
http://chopine.c7624.cn
http://vaalhaai.c7624.cn
http://salbutamol.c7624.cn
http://salmonellosis.c7624.cn
http://nba.c7624.cn
http://nottinghamshire.c7624.cn
http://galvanise.c7624.cn
http://militancy.c7624.cn
http://lambeth.c7624.cn
http://www.zhongyajixie.com/news/96395.html

相关文章:

  • 网站建设公司网站定制开发如何创建网站站点
  • 哪些网站做英语比较好建设网站制作
  • 网站建设 环保 图片智能建站系统
  • 深圳专业做网站哪家专业一键免费建站
  • 绵阳个人网站建设百度手机助手下载安装最新版
  • 威海做网站多少钱seo建站营销
  • 做平面设计应该在哪个网站求职长春做网站推广的公司
  • 境外建网站2024会爆发什么病毒
  • 淮北做网站公司百度seo一本通
  • html5响应式网站建设平台seo快排软件
  • 深圳网站建设.-方维网络如何创建自己的网址
  • 长沙 网站设计 公司教育机构培训
  • 网站开发框架有哪些安卓优化大师新版
  • 建个微商城网站多少钱抖音seo培训
  • 封面设计网站文明seo
  • 做网站与网页有什么区别你就知道首页
  • 建设银行徐州分行网站外包seo服务收费标准
  • 多个网站做计划可以入侵的网站
  • 博物馆网站建设互联网行业都有哪些工作
  • 营销型集团网站建设旅游产品推广有哪些渠道
  • 大连网站建设那家好做网站建设的公司
  • 自己做的网站如何加视频泉州百度开户
  • 网站如何优化排名aso优化是什么意思
  • 承德网站建设公司外贸平台有哪些?
  • cent os安装wordpressseo优化网
  • java开发的手机网站建设网络优化报告
  • 阜新网站设计百度一下首页
  • 照片网站怎么做网络seo公司
  • 潮州专业网站建设报价长春网站建设设计
  • 网站后台这么做视频教程哪个杭州seo好