Wednesday, 15 August 2012

php - DISTINCT after ORDER BY -



php - DISTINCT after ORDER BY -

i'm creating forum. i'm outputting topics 'posts' , 'members' table joined it. way can display post , fellow member info on topic index.

what i'm trying collect username of lastly 3 members posted, want unique values (no duplicates in case double posts) i'm using distinct, problem usernames grouped after they're ordered backwards. if did first , lastly post, won't able retrieve username among list.

here's code i'm using:

substring_index( group_concat(distinct `members`.`username` order `posts`.`date` desc separator '\\\\') , '\\\\', 3 ) member_last_username

is there way modify code usernames ordered backwards before grouping? apologize if question confusing!

sure, subselect orders info way want , utilize input.

select substring_index( group_concat(distinct sub.username order sub.`date` desc separator '\\\\') , '\\\\', 3 ) member_last_username (select m.username, p.`date` members m inner bring together post p on (some bring together or other) order backwards ordering ) sub

php mysql

No comments:

Post a Comment