By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,009 Members | 1,643 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,009 IT Pros & Developers. It's quick & easy.

clarification on GROUP_CONCAT()

P: 8
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:
Expand|Select|Wrap|Line Numbers
  1.  
  2.          function checking_query() {
  3.         global $connection;
  4.         $query = "SELECT GROUP_CONCAT(userId) FROM owner";
  5.         $result = mysql_query($query, $connection);
  6.         confirm_query($result);
  7.         var_dump($result);
  8.     }
  9.  
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
May 31 '12 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 1,035
Expand|Select|Wrap|Line Numbers
  1. mysql> select * from tbl2;
  2. +----------+----------+----------+
  3. | colA     | colB     | colC     |
  4. +----------+----------+----------+
  5. | 33996344 | 33996351 | 33996344 |
  6. | 50331648 | 68257567 | 50331648 |
  7. | 67276832 | 68257567 | 67276832 |
  8. +----------+----------+----------+
  9. 3 rows in set (0.00 sec)
  10.  
  11. mysql> select group_concat(colA) from tbl2;
  12. +----------------------------+
  13. | group_concat(colA)         |
  14. +----------------------------+
  15. | 33996344,50331648,67276832 |
  16. +----------------------------+
  17. 1 row in set (0.00 sec)
  18.  
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?
Jun 2 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.