Outputting columns into list format
Quick question. I have 2 columns in SQL broken out like so:
| number | fruits |
|---|---|
| 1 | apple |
| 2 | apple |
| 1 | orange |
| 1 | pear |
| 2 | pear |
| 3 | pear |
I need a comma separated output like so:
1,2 apple
1 orange
1,2,3 pear
I've messed around with cf function ValueList and SQL Select like so:
<cfquery name="qFruits">
SELECT number, fruits
FROM table
WHERE (fruits = 'apple')
GROUP BY number, fruits
ORDER BY fruits
</cfquery>
<table
<tbody>
<cfoutput query="qFruits" group="fruit">
<tr>
<td>#valuelist(qFruits.number)#</td>
<td>#fruits#</td>
</tr>
</cfoutput>
</tbody>
</table>
and am able to get the individual fruit output:
1,2 apple
but not sure how to modify my code to get all fruits/numbers. Thanks.