What you are trying to create is called a "pivot table" or a "cross-tab report". I recently walked someone else through this same process. Read through this thread and let me know if it helps you or not. You can also Google the groups for "MySQL pivot table" and find other examples and methods.
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&safe=off&threadm=cautac%243u8%241%40FreeBSD.csie.NCTU.edu.tw&rnum=1&prev=/groups%3Fq%3DMySQL%2Bpivoting%2Btable%2Bsgreen%26ie%3DUTF-8%26hl%3Den Best Wishes, Shawn Green Database Administrator Unimin Corporation - Spruce Pine Mauricio Pellegrini To: MySql List <[EMAIL PROTECTED]> <[EMAIL PROTECTED] cc: com.ar> Fax to: Subject: How to turn rows into columns 06/29/2004 04:35 PM Please respond to hrrg-inf Hi , Sorry to ask this question, but I'm in desperate need to acomplish this report, and don't even know it is possible to be done. The thing is I have to turn rows from one table into columns in other table. The first table looks like this T1 ----------- id cod ----------- 1 bb 1 ff 1 gg 1 kk 2 rr ----------- An it should be converted to the following format where every cod value pertaining to T1 should be located into T2 under the specified column T2 ----------------------------------- id c1 c2 c3 c4 ----------------------------------- 1 bb ff gg kk 2 rr ----------------------------------- I know how to perform this under other languages but don't know how to do it with mysql's sql. I think someone else must have had the same requirement before, at least I hope so. Thanks in advance, Mauricio -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]