Hi spacemarc,

spacemarc wrote:
Hi all,
I have this query:

SELECT tableA.*, COUNT(*) AS Tot
FROM tableB
LEFT JOIN tableA ON tableA.uid=tableB.uid
GROUP BY tableA.uid

This query shows only the users (tableA) that are in tableB with at
least 1 record (like total) but not the users that have 0 record.

How can I obtain all users, also those with 0 record??

Use a LEFT OUTER JOIN, but reverse it; join from tableA to tableB.

You may be looking for a FULL OUTER JOIN, I'm not sure. MySQL doesn't support that, but see: http://www.xaprb.com/blog/2006/05/26/how-to-write-full-outer-join-in-mysql/

Baron

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

Reply via email to