1

I would like to re-order rows from two columns in an existing table without creating a new one. I have this script, that works, table name test.table:

   SELECT value, variety
    FROM test.table
    group by value, variety
    order by value, variety;

I have tried update and alter table, but I can not get it to work e.g:

update test.table
SELECT value, variety
FROM test.table
group by value, variety
order by value, variety;

How is this done?

anna
  • 195
  • 2
  • 9

1 Answers1

0

I think you should have a look at this qustion and answer for using group by and orde by together.

Community
  • 1
  • 1
waheed
  • 134
  • 1
  • 8
  • my script works, I just do not understand how to apply it to the table. How to alter it. Do I **have to** create a new one using create table? – anna Feb 11 '16 at 10:13
  • 1
    You should then create a "view", SQL table can not be used to store grouped and ordered data. it is simply ordered in default insertion order. – waheed Feb 11 '16 at 10:52
  • 1
    Please read [thi page](http://www.w3schools.com/sql/sql_view.asp) for basic info about creating views in mysql – waheed Feb 11 '16 at 11:04