【问题标题】:This is not permitted when the subquery follows = != < <= > >= or when the subquery is used as an expression当子查询跟随 = != < <= > >= 或子查询用作表达式时,这是不允许的
【发布时间】:2015-08-30 04:57:26
【问题描述】:
delete from gust_card

where gust_card.c_id =
(select gust_card.c_id``
from gust_card,booking,room
where
 gust_card.c_id=booking.c_id and
booking.room_id=room.room_id
and room.stranded='deluxe ' )

我想删除预订“豪华”客房的客户记录。

room table>> room_id , standard

guest_card table>> guest_id, guest name

booking table >> booking_id ,room_id,guest_id

【问题讨论】:

    标签: sql-server sql-server-2008 sql-delete


    【解决方案1】:

    你必须用“IN”替换等号

    WHERE gust_card.c_id
    IN (SELECT  gust_card.c_id
    

    因为子选择可以返回多个结果行。使用“in”可以删除子选择结果列表中具有 id 的所有行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多