How to make value in ascending order in the mysql?


Problem :

I want this type of output to fetch task_name from database like in this format

Task 10 Task 2 Task 3 Task 5........

My Query is

 SELECT task_name, section_name, ref_student_id
 FROM scores
 WHERE ref_student_id = '".$studentid."'
    AND section_name = 'sm1'
 GROUP BY task_name

So I want to output like this..

 Task 2 Task 3 Task 5 Task 10........


Solution :

use this

"SELECT task_name, section_name, ref_student_id
 FROM scores
WHERE ref_student_id = '1'
AND section_name = 'sm1'
GROUP BY task_name
ORDER BY cast( SUBSTRING( task_name, 5 ) AS unsigned ) ASC"   

Mysql Tutorials

Mysql Howto..

How to conduct an Accent Sensitive search in MySql

How to add field in MySQL result?

How to get size of mysql database?

How to use MySQL view in django?

How to perform large query on multiple MySQL tables?

How to use new format

How to trace MySql queries using MySql-Proxy?

PHP + MySQL: How to select values from a checkbox

How do I specify that “NOW()” refer to a 24-hour clock in a mysql query (as opposed to 12 hour)?

How do I migrate my site from mysql to mysqli? [duplicate]

How to merge multiple tables with similar names in MySQL [duplicate]

How to convert from windows-1257 to utf-8 (mysql)

How to obtain a value from previous day in a query

configuring how to pull data out of 3 tables with mysql

How to export 20 000 contacts from MySQL database via PHP for import into an desktop address book?

How to use java variable to insert values to mysql table?

How to import latitude/longitude data correctly into MySQL?

How to save Facebook comments count to Mysql database?

how to fetch a number of rows…from table in mysql using php

Talend: How to create a table in MySql DB and populate using CSV file? [closed]

PDO how do I returns the total number of executed queries

how to monitor database transaction?

Php/Mysql game: how to implement over the time upgrades

How does MySQL handle storing ENUM value that doesn't exist?

How to lock row in mysql without blocking?

how to insert dynamic form fields into mysql using php [closed]

how to implement unique IDs across many tables

how to get subject names and total of missed homework in each subject from MySQL/PHP

How to know when escape is necessary for MySQL

How to add new content when a checkbox is clicked?