Hi,
you can use:
SELECT COUNT(B.Booking_ID), User_Location
FROM Users U
LEFT JOIN Bookings B ON U.User_ID = B.User_ID
GROUP BY(U.User_Location);

/Johan

shaun thornburgh wrote:

Hi,

The following table produces a query that shows all bookings that user has made and groups the number of bookings by the users location code.

mysql> SELECT COUNT(B.Booking_ID), User_Location FROM Bookings B, Users U WHERE U.User_ID = B.User_ID GROUP BY(U.User_Location);

At the momnet if no bookings are made by a particular user then their location isnt included in the result. Is it possible to modify this query so that if no bookings are made for a particlar location then the location is still included in the result i.e.

+---------------------+---------------+
| COUNT(B.Booking_ID) | User_Location |
+---------------------+---------------+
|                   1 | 01            |
|                   8 | 02          |
|                   9 | 03          |
|                   1 | 04           |
|                   1 | 05          |
|                   2 | 06           |
|                   1 | 07          |
...

Many thanks for your help

_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger today! http://www.msn.co.uk/messenger





--
Johan Höök, Pythagoras Engineering Group
                - MailTo:[EMAIL PROTECTED]
                - http://www.pythagoras.se
Pythagoras AB, Stormbyv. 2-4, SE-163 55 SPÅNGA, Sweden
Phone: +46 8 760 00 10 Fax: +46 8 761 22 77



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to