1

I'm newest newbie to Database and learning to use MySQL.
I want to cut the data by every 10 row, and paste it to new columns.
Function of "Partition" seems available in these situation, but I can't figure out how it works.
Just to want to know way convenient than cut and paste in Excel..

(Please take a look at pictures : http://doremifafa.egloos.com/1147359)

Data to Revise:


(source: egloos.com)

I want it to look like this:

http://thumbnail.egloos.net/600x0/http://pds21.egloos.com/pds/201310/07/05/f0238705_5252617b8c1f4.png

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
  • 2
    Can you elaborate a bit on what you're trying to achieve? Normally, when working with data in a database, you are not concerned with the individual row. Instead, you perform all your business logic using database set operations that apply to all your rows at once, instead of 10 rows at a time. – Dan Oct 07 '13 at 06:36

1 Answers1

0

When I look at your picture, it seems like you want to do the reverse, that is, take values from different columns and 'paste' these underneath each other to create a lot of rows and only two columns. Is that right?

If so, you could do it like this (using dummy Col1, 2, 3 fields since I don't know your actual column and table names).

select 
  Col1, Col2, Col3 
from 
  YourTable 
union all
select 
  Col4, Col5, Col6 
from 
  YourTable 
union all
select 
  Col7, Col8, Col9 
from 
  YourTable 
...
GolezTrol
  • 114,394
  • 18
  • 182
  • 210
  • Oh, the pictures are uploaded in reverse order. I want to do that in opposite way. (from table with long rows to "wider" one.... Anyway,, thank you for kind reply. – user2853465 Oct 07 '13 at 07:25
  • In that case, the thing you are looking for is a `pivot table`. Have a look at [this question](http://stackoverflow.com/questions/7674786/mysql-pivot-table) – GolezTrol Oct 07 '13 at 07:36
  • Many thanks!!!! Problem solved ^-^; referring http://buysql.com/mysql/14-how-to-automate-pivot-tables.html – user2853465 Oct 07 '13 at 08:20