The technique to do this is called a cross-tab(ulation) query or a pivot
table.  A simple (and pretty static) cross-tab query can be created by the
use of CASE WHEN.  But if you want a more generic solution that works for
all values, it gets a bit more complex.  Spend some time investigating
Google hits for searches on MySQL Crosstab, etc.

HTH,
Tore.


----- Original Message -----
From: "Vivian Wang" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, February 28, 2003 10:29 AM
Subject: mysql: change column to row


> mysql,
>
> Can I change the table one column to one row like this?
> Table1:
> key, count
> A 123
> B 456
> C 789
>
> to
>
> Table2:
> A B C
> 123 456 789
>
>
>
> Thanks,
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to