Mysql select 查询正常但在更新查询时出错

Mysql select query working but giving error on update query

我有一个 select 查询工作正常。

select t1.HOST, t1.portalId from table1 t1, table2 t2
where SUBSTRING_INDEX(t1.HOST, '.',1)= SUBSTRING_INDEX(t2.HOST, '.', 1)

但是,类似的更新查询给出了错误

update table1  set table1.portalId = table2.portalId,
where SUBSTRING_INDEX(table1.HOST, '.',1)= SUBSTRING_INDEX(table2.HOST, '.', 1)

Getting error: "Unknown Column table1.HOST in where clause"

您可以使用:

update table1
JOIN table2 
  ON SUBSTRING_INDEX(table1.HOST, '.',1)= SUBSTRING_INDEX(table2.HOST, '.', 1)
set table1.portalId = table2.portalId
-- WHERE ...