Any1 know how to sort a data table?

  • Chris4beh
  • Novice
  • Novice
  • No Avatar
  • Joined: Apr 20, 2008
  • Posts: 18
  • Status: Offline

Post April 29th, 2008, 9:55 pm

On the internet just show how to sort before bind to gridview and etc

but I wan to sort the table to put the no for each row,anyone can help?

Then if got the column got same value,then how? For example:

Table
Column1 column2
a 7
b 3
c 3
d 5

need to sort by the column2
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post April 29th, 2008, 9:55 pm

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23404
  • Loc: Woodbridge VA
  • Status: Offline

Post April 29th, 2008, 10:02 pm

google search "order by"

For example
http://www.w3schools.com/sql/sql_orderby.asp
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • Chris4beh
  • Novice
  • Novice
  • No Avatar
  • Joined: Apr 20, 2008
  • Posts: 18
  • Status: Offline

Post April 29th, 2008, 10:47 pm

you miss undestood alr,cos I am try to sort is datatable ,not sql component.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23404
  • Loc: Woodbridge VA
  • Status: Offline

Post April 30th, 2008, 5:47 am

Perhaps you should specify what application you are using then, because it makes a difference. If you are using a web application then you sort the SQL/MySQL when creating the data grid. If you are using Access, Access has a built in sort function. I'm sorry I missunderstood what you wanted to know but it's because you weren't clear enough with your question.
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • Bogey
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8211
  • Loc: USA
  • Status: Offline

Post April 30th, 2008, 4:31 pm

The SQL if I understood you correctly

For Ascending
Code: [ Select ]
ALTER TABLE `table` ORDER BY `field`

For Descending
Code: [ Select ]
ALTER TABLE `table` ORDER BY `field` DESC

Where `field` is a primary key. (Not sure if it's necessary that field be a primary key. Doesn't work for me if it isn't).
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • neksus
  • Mastermind
  • Mastermind
  • User avatar
  • Joined: Sep 10, 2004
  • Posts: 2194
  • Loc: Canada
  • Status: Offline

Post May 1st, 2008, 7:18 am

I don't think he's using SQL.
  • Bogey
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8211
  • Loc: USA
  • Status: Offline

Post May 1st, 2008, 2:08 pm

By "...not sql component." I think he means the "order by". He wants to change the order of the DATABASE and that SQL does just that. All you have to do is go on SQL in the table in phpMyAdmin.
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • sammehta
  • Born
  • Born
  • No Avatar
  • Joined: Jun 17, 2009
  • Posts: 1
  • Status: Offline

Post June 17th, 2009, 6:02 am

just fill the data in datatable...

then use
datatble.defaultview.sort = "column name";
  • hgun77
  • Graduate
  • Graduate
  • User avatar
  • Joined: Jun 29, 2005
  • Posts: 164
  • Loc: Malaysia
  • Status: Offline

Post June 17th, 2009, 9:16 pm

else you may try to use javascript, doing sorting in DOM.
Malaysia > KL > TAR College

Post Information

  • Total Posts in this topic: 9 posts
  • Users browsing this forum: No registered users and 173 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.