这个更新查询中的错误是什么?

时间:2022-07-28 15:40:26
UPDATE HotelSourceMap 
SET hsm.hotelid = co.hotelid 
FROM HotelSourceMap AS hsm 
JOIN hotels AS co 
ON (hsm.hotelname= co.[name] 
AND hsm.cityid = co.cityid)

It's giving me error: The multi-part identifier "hsm.hotelid" could not be bound.

它给了我一个错误:多部分标识符“hsm”。hotelid“不能被约束。

3 个解决方案

#1


3  

Assuming the field hotelid exists in the table try changing:

假设字段hotelid存在于表中,请尝试更改:

UPDATE HotelSourceMap SET hsm.hotelid ...

to

UPDATE HotelSourceMap hsm SET hsm.hotelid ...

or alternatively

或者

UPDATE HotelSourceMap SET hotelid ...

#2


1  

Try this :-

试试这个:

UPDATE 
    hsm
SET 
    hotelid = co.hotelid 
FROM 
    HotelSourceMap hsm,
    Hotels co
WHERE
  hsm.hotelname= co.[name] AND hsm.cityid = co.cityid

In your main statement, you say you want to update HotelSourceMap.

在您的主要语句中,您说要更新HotelSourceMap。

In your SET, you try to update a field belonging to a logically different entity, hsm.

在您的集合中,您尝试更新属于逻辑上不同的实体hsm的字段。

#3


0  

Correction, you need to use the alias as the UPDATE table:

更正,需要使用别名作为更新表:

UPDATE hsm
SET....
FROM HotelSourceMap AS hsm
....

#1


3  

Assuming the field hotelid exists in the table try changing:

假设字段hotelid存在于表中,请尝试更改:

UPDATE HotelSourceMap SET hsm.hotelid ...

to

UPDATE HotelSourceMap hsm SET hsm.hotelid ...

or alternatively

或者

UPDATE HotelSourceMap SET hotelid ...

#2


1  

Try this :-

试试这个:

UPDATE 
    hsm
SET 
    hotelid = co.hotelid 
FROM 
    HotelSourceMap hsm,
    Hotels co
WHERE
  hsm.hotelname= co.[name] AND hsm.cityid = co.cityid

In your main statement, you say you want to update HotelSourceMap.

在您的主要语句中,您说要更新HotelSourceMap。

In your SET, you try to update a field belonging to a logically different entity, hsm.

在您的集合中,您尝试更新属于逻辑上不同的实体hsm的字段。

#3


0  

Correction, you need to use the alias as the UPDATE table:

更正,需要使用别名作为更新表:

UPDATE hsm
SET....
FROM HotelSourceMap AS hsm
....