Steve Tinsley
asked on
SQL Count (with joins) Help
I am creating a simple booking system.. I wont to create 1 query which pull the GROUPS / OPTIONS & How may places left for each.
These are my tables.
user
bookingGroup
bookingOption
user_bookingOption
I want a query like below with one more column to this show how many bookings there has already been. That way I can minus bookingOptionAmount from how many there has already been to get how many is left
The query to get what i want is something think this.
Steve
These are my tables.
user
bookingGroup
bookingOption
user_bookingOption
I want a query like below with one more column to this show how many bookings there has already been. That way I can minus bookingOptionAmount from how many there has already been to get how many is left
SELECT *, bookingGroup.bookingGroupId, (
FROM bookingGroup
LEFT JOIN bookingOption ON (bookingGroup.bookingGroupId = bookingOption.bookingGroupId)
The query to get what i want is something think this.
SELECT count(user_bookingOption.userId) as placesTaken
FROM bookingOption
LEFT JOIN user_bookingOption ON (bookingOption.bookingOptionID = user_bookingOption.bookingOptionID)
WHERE bookingOption.bookingOptionId = bookingOption.bookingOptionId
GROUP BY(bookingOption.bookingOptionID)
Just want to combine it to the above query. Can I do this??Steve
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER