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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.