![]() |
|
#1
|
|||
|
|||
How to sort in MySQL?Now for any easy question
Can I select from a table and sort the data from a column and then sort again from another column? An example to clear the mud (waffle) PHP Code:
Now the data in column a is sorted into data X and data Y Can I now sort the data X and data Y by column b so that data X is in order and data Y is in order? I tried PHP Code:
|
|
#2
|
||||
|
||||
Sorting multi columns in a MySQL table with ORDER BYYou can sort multi columns easily in a table / SQL Select statement using MySQL's ORDER BY clause.
So, when you want to sort or 'order by' multi columns, you just list the coloumn names in the order of their precedence (left > right), each separated by a comma. Let's say you have a table like this: Code:
PHP Code:
Code:
PHP Code:
Code:
PHP Code:
Code:
__________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#3
|
|||
|
|||
|
Ah I see why when I tried that one it didnt work for me! I missed the ' ' around the extra column.
Now a further extension to this. Part of my information (numerical) is pulled from a table and uses another php document for the awarding of points. ie 2 in my goals column and 1 in my assist column, points column is set at 0. Using my points.php this awards 2 points for each goal and 1 point for each assist. Total = 5 points PHP Code:
$points is included in the row recall. Can I now get all the rows to sort by points? I suspect that I can by using an array but I am unsure of how i go about it. There again I am probably barking up the wrong tree! :0 |
|
#4
|
||||
|
||||
|
Try explaining that again, couldn't quite work it out in my head!
It might be wiser to start a whole new thread if this 2nd question is unrelated to the first post / issue. __________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
Recent GIDBlog
First week of IA training by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Windows: From only £20p/y,Linux: from $10p/m. ASP, ASP.NET, PHP, Free MySQL, +More | EyotaHosts | Web Hosting Advertisements & Offers | 0 | 28-Jun-2003 13:54 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The