mysql数据库update、delete、和insert into表的时候,如果要使用表别名,必须按照规范写法来写:
insert:
简写:insert into t_a a(a.id, a.name) values(1, '张三'),执行结果:报错
规范写法:还没查到怎么在insert的时候使用表别名
update:
简写:update t_a a set a.name = '张三' where a.id = 1,执行结果:不报错,但是数据没有更新
规范写法:update a set a.name = '张三' from t_a a where a.id = 1,执行结果:数据更新
delete:
简写:delete from t_a a where a.id = 1,执行结果:报错
规范写法:delete a from t_a a where a.id = 1,执行结果:正常删除
目前还没遇到要要使用别名的update,delete,insert场景,一般也用不到。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)