Below is a query which gives me the Usernames of the Last-10 Visitors to a Member’s Profile…
// FORMER QUERY
$q8 = "SELECT COALESCE(m.username,'Non-Member') AS username
FROM visitor_log AS v
LEFT OUTER JOIN member AS m
ON m.id = v.visitor_id
WHERE v.member_viewed_id=?
ORDER BY v.created_on DESC
LIMIT 10";
It produces output like this…
The last 10 Visitors on this page were…
username4
username4
JohnDoe
JohnDoe
Non-Member
Non-Member
Non-Member
Non-Member
Non-Member
Non-Member
Is there a way to use DISTINCT so that I would instead get a list like this…
The last 10 Visitors on this page were…
username4
JohnDoe
Non-Member
// FORMER QUERY
$q8 = "SELECT DISTINCT(COALESCE(m.username,'Non-Member')) AS username
FROM visitor_log AS v
LEFT OUTER JOIN member AS m
ON m.id = v.visitor_id
WHERE v.member_viewed_id=?
ORDER BY v.created_on DESC
LIMIT 10";
I tried using DISTINCT several times last night to no avail, so I came here today to ask for help.
If I knew what I was doing wrong, then I wouldn’t have needed help.
I made an honest effort here…
your propensity to ask, and ask, and ask for free help is just sometimes so annoying, you know?
But it is no where near as annoying as your perpetual whining that my Threads on SP don’t meet your approval…
please give me a suggestion for how i should gently advise you to RTFM before posting
The MySQL Manual looks like it was written by English flunkies… (Could be one reason I don’t use it often - as opposed to how I do look at the PHP Manual regularly.)
It might also be the fact that no amount of searching I did pulled up anything about using DISTINCT and COALESCE together, so I came here instead…
No one makes you read or respond to my threads, or is there a masked man - with gun in hand - forcing your hands to the keyboard, AGAIN??