If I have a table that lists names and ages then can I run a single query that will give me all names of people with a particular age.
e.g.
name      age
----------|-------
alice      20
bob        21
chris      20
dave       23
eric       26
fred       29
greg       20
I want my query to return a list, separated by a comma, of all people who are aged 20.
e.g.
select (concat(name,',')) from people where age='20'
And this outputs:
alice,chris,greg
Obviously I could just do:
select name from people where age='20'
And then loop through the results in PHP but I am trying to do all of this in a query
 
     
     
     
    