Announcement

Announcement Module
Collapse
No announcement yet.

query in Order by

Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • query in Order by

    hi team,
    i have a query....

    I have a list of all countries in my MySQL db. while fetching the rows these will be displayed in alphabetical order. but i need Australia and New Zealand in the first and second places and rest as usual in alphabetical order. can u get me query for this please

  • #2
    You could add new column: sort_col tinyint default 1 ; and modify two rows with Australia and New Zeland ( sort_col = 0 )

    select columns from table order by sort_col, name

    Inside mysql:
    Australia 0
    Austria 1
    New Zeland 0
    Greece 1
    Belgium 1

    results from query:
    Australia 0
    New Zeland 0
    Austria 1
    Belgium 1
    Greece 1

    Comment

    Working...
    X