MYSQL 错误不唯一 table/alias SQL 使用 INNER JOIN 加入 table
MYSQL Error Not unique table/alias SQL join table with INNER JOIN
我尝试使用 INNER 连接在数据库中更新我的 table,但它一直显示错误
我正在使用 MYQSL 5.5
这是我在 mapper
中的代码
UPDATE room_availability INNER JOIN room_availability ON list_hotel.hotel_id = room_availability.hotel_id
INNER JOIN room_price ON room_availability.hotel_id = room_price.hotel_id SET ${Room_type}_room = #{kamarBaru},room_date = #{booking_date}
WHERE list_hotel.nama_hotel = #{hotel_name};
这里是错误
### Error updating database. Cause: java.sql.SQLSyntaxErrorException: Not unique table/alias: 'room_availability'
### The error may involve Hotel.insertUpdateRoom-Inline
### The error occurred while setting parameters
### SQL: UPDATE room_availability INNER JOIN room_availability ON list_hotel.hotel_id = room_availability.hotel_id INNER JOIN room_price ON room_availability.hotel_id = room_price.hotel_id SET deluxe_room = ?,room_date = ? WHERE list_hotel.nama_hotel = ?;
### Cause: java.sql.SQLSyntaxErrorException: Not unique table/alias: 'room_availability'] with root cause
java.sql.SQLSyntaxErrorException: Not unique table/alias: 'room_availability'
这是我在 SQLYog 中设计的数据库
有人能告诉我我哪里做错了吗?
这可能有效:
UPDATE room_availability
SET ${Room_type}_room = #{kamarBaru},room_date = #{booking_date}
FROM room_availability
INNER JOIN list_hotel ON list_hotel.hotel_id = room_availability.hotel_id
INNER JOIN room_price ON room_availability.hotel_id = room_price.hotel_id
WHERE list_hotel.nama_hotel = #{hotel_name};
我尝试使用 INNER 连接在数据库中更新我的 table,但它一直显示错误 我正在使用 MYQSL 5.5 这是我在 mapper
中的代码UPDATE room_availability INNER JOIN room_availability ON list_hotel.hotel_id = room_availability.hotel_id
INNER JOIN room_price ON room_availability.hotel_id = room_price.hotel_id SET ${Room_type}_room = #{kamarBaru},room_date = #{booking_date}
WHERE list_hotel.nama_hotel = #{hotel_name};
这里是错误
### Error updating database. Cause: java.sql.SQLSyntaxErrorException: Not unique table/alias: 'room_availability'
### The error may involve Hotel.insertUpdateRoom-Inline
### The error occurred while setting parameters
### SQL: UPDATE room_availability INNER JOIN room_availability ON list_hotel.hotel_id = room_availability.hotel_id INNER JOIN room_price ON room_availability.hotel_id = room_price.hotel_id SET deluxe_room = ?,room_date = ? WHERE list_hotel.nama_hotel = ?;
### Cause: java.sql.SQLSyntaxErrorException: Not unique table/alias: 'room_availability'] with root cause
java.sql.SQLSyntaxErrorException: Not unique table/alias: 'room_availability'
这是我在 SQLYog 中设计的数据库
有人能告诉我我哪里做错了吗?
这可能有效:
UPDATE room_availability
SET ${Room_type}_room = #{kamarBaru},room_date = #{booking_date}
FROM room_availability
INNER JOIN list_hotel ON list_hotel.hotel_id = room_availability.hotel_id
INNER JOIN room_price ON room_availability.hotel_id = room_price.hotel_id
WHERE list_hotel.nama_hotel = #{hotel_name};