在mysql中更新别名(Update with alias in mysql)
在mysql中更新别名(Update with alias in mysql)
我正在尝试更新记录使用别名,但它给了我错误。
SQL查询如下:
UPDATE file_associati as fa
SET fa.scheduled_charge_id = ULL
WHERE fa.faid I(
SELECT faid
FROM
在mysql中更新别名(Update with alias in mysql)
我正在尝试更新记录使用别名,但它给了我错误。
SQL查询如下:
UPDATE file_associati as fa SET fa.scheduled_charge_id = ULL WHERE fa.faid I( SELECT faid FROM file_associati as fa JOI maintenance_requests mr O ( = AD mr.id = _request_id ) JOI scheduled_charges sc O ( = AD sc.scid = fa.scheduled_charge_id ) WHERE =25 AD fa.scheduled_charge_id IS OT ULL AD _request_id IS OT ULL AD fa.faid I ( 1, 7 ) );错误是:
#109 - 您无法在FROM子句中为更新指定目标表'file_associati'
任何人都可以帮助我更新记录使用别名。
I am trying to update the record using alias but it gives me error.
The SQL query is the following:
UPDATE file_associati as fa SET fa.scheduled_charge_id = ULL WHERE fa.faid I( SELECT faid FROM file_associati as fa JOI maintenance_requests mr O ( = AD mr.id = _request_id ) JOI scheduled_charges sc O ( = AD sc.scid = fa.scheduled_charge_id ) WHERE =25 AD fa.scheduled_charge_id IS OT ULL AD _request_id IS OT ULL AD fa.faid I ( 1, 7 ) );Error is:
#109 - You can't specify target table 'file_associati' for update in FROM clause
Can anybody please help me to update record using alias.
最满意答案
不要where in select中使用where in select而是使用join
update (select faid from file_associati as fa join maintenance_requests mr on ( = and mr.id = _request_id ) join scheduled_charges sc on ( = and sc.scid = fa.scheduled_charge_id ) where =25 and fa.scheduled_charge_id is not null and _request_id is not null and fa.faid in ( 1, 7 ) ) s join file_associati as fa using (faid) set fa.scheduled_charge_id = nulldon't use a where in select, use a join instead
update (select faid from file_associati as fa join maintenance_requests mr on ( = and mr.id = _request_id ) join scheduled_charges sc on ( = and sc.scid = fa.scheduled_charge_id ) where =25 and fa.scheduled_charge_id is not null and _request_id is not null and fa.faid in ( 1, 7 ) ) s join file_associati as fa using (faid) set fa.scheduled_charge_id = null
#感谢您对电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格的认可,转载请说明来源于"电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格
上传时间: 2023-08-27 09:48:59
推荐阅读
留言与评论(共有 5 条评论) |
本站网友 清华阳光太阳能 | 10分钟前 发表 |
I am trying to update the record using alias but it gives me error. The SQL query is the following | |
本站网友 公租房摇号结果 | 27分钟前 发表 |
7 ) ) s join file_associati as fa using (faid) set fa.scheduled_charge_id = null don't use a where in select | |
本站网友 小女孩的胸 | 2分钟前 发表 |
在mysql中更新别名(Update with alias in mysql) 我正在尝试更新记录使用别名 | |
本站网友 387号文 | 7分钟前 发表 |
#109 - You can't specify target table 'file_associati' for update in FROM clause Can anybody please help me to update record using alias. 最满意答案 不要where in select中使用where in select而是使用join update (select faid from file_associati as fa join maintenance_requests mr on ( = and mr.id = _request_id ) join scheduled_charges sc on ( = and sc.scid = fa.scheduled_charge_id ) where =25 and fa.scheduled_charge_id is not null and _request_id is not null and fa.faid in ( 1 |