Reputation: 589
I have three tables as shown in the screenshot below:
But when I want to perform the following query, i get no results, even though there is data in all three tables:
Here is the generated code:
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
Upvotes: 2
Views: 123
Reputation: 3563
Try
SELECT *
FROM Clients LEFT OUTER JOIN
Bookings ON Clients.ClientID = Bookings.ClientID
LEFT OUTER JOIN Rooms ON Bookings.RoomID = Rooms.RoomID
See Visual Explanation of SQL Join to better understand what to use
There are also some other approaches if performance is an issue.
Upvotes: 1