I hope someone can help me out with this problem
I have two tables one for users holding all there info each user has a
unique ID. I also have a table that records each transaction each
transaction has a unique ID and the ID of the user who made the transaction.
I whish to do and SQL query that return a table that has the user ID, user
name, and the number of transactions that user has pereformed.
Here is a simplified version of my query :

SELECT DISTINCT(u.user_ID),COUNT(t.trans_ID) as total,u.f_name,u.l_name FROM
users u,transactions t WHERE u.user_ID=t.user_ID GROUP BY u.user_ID";

The problem is if a user hasn't made any transactions they won't appear in
the results of the above query because they won't have had thier ID in the
transactions table.
Can anyone help me generate a query that will return all users and if they
have an transaction(s) the count of that and if none then null or zero.

TIA
Jamie


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to