468,541 Members | 1,740 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,541 developers. It's quick & easy.

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:
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
1 1665
Luuk
1,043 Expert 1GB
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.

Similar topics

3 posts views Thread by Wes | last post: by
4 posts views Thread by Shea Martin | last post: by
3 posts views Thread by John D. Sanders | last post: by
2 posts views Thread by Ethan | last post: by
9 posts views Thread by Adam | last post: by
3 posts views Thread by solomon_13000 | last post: by
reply views Thread by chanchito_cojones | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.