Inserting sorted values from one MySQL table into another table -
i have 2 tables, average_table , position_table. have 2 column each. copy sorted data average_table position_table shown below
the average_table looks this
std_id avr 001 23.4 002 34.7 003 13.9 004 56.8 then position_table should this:
std_id avr 004 56.8 002 34.7 001 23.4 003 13.9 when used following sql queries, result no different between average_table , position_table. can 1 me out please?
try { string str = "insert position_table select * average_table order avr desc"; rs = st.executequery(str); } catch(sqlexception ce){system.out.print(ce)}
in sql world rows aren't sorted. there might way in mysql (in sql server, think clustered might - reason getting rows in order).
in other words, inserted row not guaranteed have specific order. sql declarative, have declare how order when query.
i don't understand you're trying achieve position table - me looks exact duplicate of average table , you're getting data in ranked order query using order by. use order when need data ordered.
Comments
Post a Comment