MySql Search Form

Discussion in 'MySQL' started by sonu21, Jan 25, 2012.

  1. #1
    Hello Friends,I have 1 query I want to search database with php code.I want to sort out results by columns.

    Like if I select category : Personal & Price: 25$ then it should sort out through this.

    Help ME

    Thanks!
     
    sonu21, Jan 25, 2012 IP
  2. QZAX

    QZAX Greenhorn

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    18
    #2
    you do it using the "order by" keyword in the select query that you have.

    at the end of your query add the code as shown below.

    select * from table_name order by category, price

    if you wish to make price as your primary sorting column and category as secondary sorting column then

    select * from table_name order by price, category

    the above statements with sort in ascending order. if you want the sort in descending order you can do it as follows

    select * from table_name order by price desc, category desc

    the keyword "desc" sorts the result in descending order. If "desc" is not used or if "asc" is used it will sort in ascending order.
     
    QZAX, Feb 8, 2012 IP