Forum Moderators: open
1. senders with sender_id
2. gifts with gift_id and sender_id
What i am trying to do is count how many gifts bought per sender using both tables. But i cannot seem to retrieve
those senders that have not sent any gifts at all. My PHP MYSQL query looks like the following:
$stmt = "SELECT tx.*, COUNT(*) AS cnt
FROM table_senders AS tx,
table_gifts AS ty USE INDEX (index_sender_and_gift)
WHERE tx.sender_id=ty.sender_id
GROUP BY ty.sender_id ORDER BY cnt DESC LIMIT $st, $end";
This works fine except it does not retrieve the senders that have not sent any gifts. Do you know how i could modify the above statement so that it corporates those senders that have sent 0 gifts? - i.e the people that would exist in the sender table but not in the gift table.
Many thanks for your time
Alina
Many thanks again
Alina