2

我有三个表,如下面的屏幕截图所示: 数据集

但是当我想执行以下查询时,我没有得到任何结果,即使所有三个表中都有数据:

询问

这是生成的代码:

SELECT Clients.ClientID, Clients.FirstName, Clients.Surname, Clients.Internal, Clients.Organisation, Clients.LandlineNo, Clients.MobileNo, Clients.Address1, Clients.Town, 
              Clients.Postcode, Clients.Email, Clients.NHS, Clients.PurchaseOrderNumber, Bookings.Date, Bookings.Timebegan, Bookings.Timefinished, Bookings.Price, 
              Bookings.Repeats, Bookings.Rweeks, Bookings.Rdays, Bookings.Rmonths, Bookings.Occurrences, Rooms.Roomname
FROM     Clients INNER JOIN
              Bookings ON Clients.ClientID = Bookings.ClientID INNER JOIN
              Rooms ON Bookings.RoomID = Rooms.RoomID
4

1 回答 1

1
Try

SELECT *
FROM     Clients LEFT OUTER JOIN
         Bookings ON Clients.ClientID = Bookings.ClientID 
         LEFT OUTER JOIN Rooms ON Bookings.RoomID = Rooms.RoomID

请参阅SQL Join 的可视化解释以更好地了解使用什么

如果性能是一个问题,还有其他一些方法。

于 2013-04-03T00:13:21.943 回答