I have the below MySQL query, which should return the t1.username
, t1.website
, in_count
(WHERE t2.type = 'in'
), out_count
(WHERE t2.type = 'out'
) and WHERE
the t1.website
field is NOT
EMPTY
or NULL
.
However its seemed to have malfunctioned (or I'm doing something wrong?), as it returns 1 result (via mysql_num_rows()
) and when i print_r()
(on the mysql_fetch_assoc()
), the keys of the columns are their however all the values are empty/blank (see below).
The print_r()
dump:
Array
(
[username] =>
[website] =>
[in_count] =>
[out_count] =>
)
The MySQL query:
SELECT t1.username,
t1.website,
SUM(IF(t2.type = 'in', 1, 0)) AS in_count,
SUM(IF(t2.type = 'out', 1, 0)) AS out_count
FROM users AS t1
JOIN referrals AS t2
ON t1.username = t2.author
WHERE NOT Isnull(t1.website)
LIMIT 0, 10
Hope all is clear, let me know if you need more information, appreciate all help. :B