Jump to content

[SOLVED] helo sorting mysql data


prakash

Recommended Posts

Hi,

 

I have 2 filed on my database. The data on that table as follows

 

FIELD1      FIELD2

================

NA              1

NA              9

NC              3

NA              4

NA              2

 

so if I query like

select * from table order by field1

 

then it will list out data like

NA1

NA9

NA4

NA2

NC3

 

but I want to order both field1 and field2 and want to display data as

 

NA1

NA2

NA4

NA9

NC3

 

so what will be my mysql query?

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/72187-solved-helo-sorting-mysql-data/
Share on other sites

SELECT * FROM table ORDER BY field1 ASC AND field2 ASC

(Doesn't quite remember if it is "AND" or a comma "," between the two statements.

 

wow thanks man

being an php programmer I never knew that mysql also supports same on "order by"

it got work on

 

SELECT * FROM table ORDER BY field1 ASC, field2 ASC

 

again thanks for your help

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.