Q: LEFT JOIN on mysql query do not get results like i want i have 2 table , awards and awards_user  , and have problem with LEFT JOIN on mysql query do not get results like i want
awards :
awardid  | name   | link  
1        | award1 | photo link    
2        | award2 | photo link   
3        | award3 | photo link   
4        | award4 | photo link 

awards_user :
awardid  | username
2        | mark      
2        | jon
3        | mark    
1        | jon

I try to get results like that :
award name  |  award photo  |  Users
award1      |      link     |  jon
award2      |      link     |  mark,jon
award3      |      link     |  mark
award4      |      link     |  -------

that is my try :
 SELECT au.username 
      , au.userid 
      , a.link 
      , a.name 
      , a.awardid 
   FROM awards a
   LEFT 
   JOIN awards_user au
     ON au.awardid = a.awardid
  WHERE a.forumid = 22
  GROUP 
     BY a.awardid 
      , au.username
  ORDER 
     BY a.awardid DESC 

the Solve the problem:
$all_awards = $db->query_read(" SELECT awards.name as name, awards.link as link, 
       GROUP_CONCAT(DISTINCT awards_user.username) AS username
   FROM awards LEFT JOIN awards_user ON (awards_user.awardid = awards.awardid)
   where awards.forumid = '".$_REQUEST['forumid']."'
   GROUP BY awards.awardid, awards.name, awards.link
  ");


A: GROUP_CONCAT does exactly what you need:
SELECT
       a.name AS name
     , a.link AS photo
     , GROUP_CONCAT(DISTINCT au.username) AS users
FROM awards AS a
     LEFT JOIN awards_user AS au ON (au.awardid = a.awardid)
GROUP BY
       a.awardid
     , a.name
     , a.link
ORDER BY
     a.awardid DESC

More info about MySQL GROUP_CONCAT here: http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat
BTW, you can even sort usernames or choose different separator if you want in group_concat. Just read MySQL manual and google "mysql group_concat examples" :)

A: and also add `` on table names because your naming conventions are pretty rough might match with mysql reserved words and again PRACTISE SECURITY FILTER YOUR INPUTS $_REQUEST['forumid'] 

A: Try this:
SELECT awards.name as award_name, award.link as award_photo, 
       GROUP_CONCAT(DISTINCT awards_user.username AS users
   FROM awards LEFT JOIN awards_user ON (awards_user.awardid = awards.awardid)
   GROUP BY awards.awardid, awards.name, awards.link;

