SQL output:
name|qty|week
abc|60|1
abc|20|2
abc|80|3
abc|22|4
bfg|23|1
bfg|45|2
bfg|633|3
bfg|90|4
jhg|34|1
jhg|23|2
jhg|20|4
I need to generate the csv file like this:
week,abc,bfg,jhg
1,60,23,34
2,20,45,23
3,80,633,, <<<< notice no data for jhg in week 3.
4,22,90,20
I had received a great response in previous thread by using arrays but this time I am not sure how to get it in this particular format. Will associative array help?
Thanks
Alex B
Another sql to csv question
Moderator: General Moderators
- andyhoneycutt
- Forum Contributor
- Posts: 468
- Joined: Wed Aug 27, 2008 10:02 am
- Location: Idaho Falls
Re: Another sql to csv question
you could just use mysql to dump the data to csv, or do you need to do this PHP-side?
-Andy
-Andy
Re: Another sql to csv question
The transformation you are looking for is similar to a crosstab query (without the totals).
Related topic: (broken) Displaying two variables nested under each other
Edit: This post was recovered from search engine cache.
Related topic: (broken) Displaying two variables nested under each other
Edit: This post was recovered from search engine cache.