clarification on GROUP_CONCAT()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • newbie93
    New Member
    • May 2012
    • 8

    clarification on GROUP_CONCAT()

    Hi everyone - I need a way to turn a column in my table into a list. Basically, my table consists of: userId, name, and "role" (0 or 1). I want to write a function that outputs a list of usernames. This is what I have:
    Code:
     
             function checking_query() {
    		global $connection;
    		$query = "SELECT GROUP_CONCAT(userId) FROM owner";
    		$result = mysql_query($query, $connection);
    		confirm_query($result);
    		var_dump($result);
    	}
    I get no result when I do this (nor do I get an error message...)
    Please help! I feel terrible wasting so much time on this issue because I have a feeling it's pretty trivial
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    Code:
    mysql> select * from tbl2;
    +----------+----------+----------+
    | colA     | colB     | colC     |
    +----------+----------+----------+
    | 33996344 | 33996351 | 33996344 |
    | 50331648 | 68257567 | 50331648 |
    | 67276832 | 68257567 | 67276832 |
    +----------+----------+----------+
    3 rows in set (0.00 sec)
    
    mysql> select group_concat(colA) from tbl2;
    +----------------------------+
    | group_concat(colA)         |
    +----------------------------+
    | 33996344,50331648,67276832 |
    +----------------------------+
    1 row in set (0.00 sec)
    With above, i can say that there is nothing wrong with your query but:
    1) does "select * from owner" return results?
    2) what does "confirm_query( $result);" do?

    Comment

    Working...