SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist barbara1712's Avatar
    Join Date
    Apr 2007
    Location
    India
    Posts
    509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    first display featured items, then non-featured (was "Query help")

    Hello guys,

    I am having the table called 'item_details' and suppose it contains 50 items
    in my table.Out of 50 suppose 30 items are featured and remaining are not.
    Now I want to display all the items in the table.
    But it should first display the featured items and then the non-featured items.

    How should I query?
    Your help will be highly appriciated.

    Thanks,
    Barbara

  2. #2
    SitePoint Zealot mwasif's Avatar
    Join Date
    Apr 2007
    Location
    Pakistan
    Posts
    102
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How do you distinuish between featured and non-featured? If you have some field for then, then simply put
    ORDER BY is_featured

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,273
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    ORDER BY is_featured DESC

    assuming is_featured=1 means it is featured, and is_featured=0 means it isn't

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  4. #4
    SitePoint Evangelist barbara1712's Avatar
    Join Date
    Apr 2007
    Location
    India
    Posts
    509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks mwasif and r937,
    I tried and got the correct results.
    Barbara


Bookmarks

Posting Permissions

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