Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Aug 2007
    Posts
    49
    Thanks
    6
    Thanked 1 Time in 1 Post

    order by two fields

    i have a two field say for example
    field1={e,a,c}
    field2={f,d,b}

    i want to display the
    abcdef

    how would i do that.
    i tried this one
    Code:
    select * from table order by field1,field2
    but the result is it will sort first the field1 and then field2
    acebdf is the result of this query but i want abcdef not this one.please help me

  • #2
    Banned
    Join Date
    Feb 2008
    Location
    Winnipeg, Canada
    Posts
    396
    Thanks
    0
    Thanked 29 Times in 29 Posts
    If you have a table setup like that then it is more than likely not normalized, you should consider normalizing all of your tables ASAP.

  • #3
    New Coder
    Join Date
    Aug 2007
    Posts
    49
    Thanks
    6
    Thanked 1 Time in 1 Post
    actually this is the problem.i have field which is idate and sdate.
    and i have a display like this

    select * from table

    Date
    if (d==1)
    $row[idate]
    else
    $row[sdate]

    my proble is since there are two fields that displays in the date.how would i sort it.
    i cant simply select * from table order by idate and sdate

    if any one know how to sort this please help me.

    i tried select * from table ordery by concat(idate,sdate)but its not working with this because niether of the field is null
    Last edited by meshi; 02-26-2008 at 12:34 PM.

  • #4
    Regular Coder meth's Avatar
    Join Date
    Jan 2003
    Posts
    262
    Thanks
    0
    Thanked 9 Times in 9 Posts
    Can you post the table schema?
    I do Web Design, Brisbane based.
    More time spent in PHP/MySQL Web Development.
    And Search Engine Optimisation takes up the rest of it.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •