Showing Specific Rows at top

  • Hi Friends,

    I am working on a shopping search engine application. I want to make the search experience area specific, like when user browse my application finds the CityName of the user from its IP address. now I want to show the products/stores in that city at the top in the search results.

    eg if user search for skirts and he is sitting in NY while browsing then skirts/ stores selling skirts in NY show come at the top of the result page.

    My StoteMaster table is very simple.

    StoreID, StoreName, toreAddress, ProductKeywords, SCountry, SZipCode, Long, Lat, SWebiste, SEmail

    Plz Help me in this to make the sql query.

    Thanks

    Rajiv Sharma

  • Select * from [TableName] where SCountry=[TheCountryNameYouGotFromIP]

    This is a sample. You can replace the * in the above query with the requisite field names.

    Hope this clarifies.

    Pradeep Adiga
    Blog: sqldbadiaries.com
    Twitter: @pradeepadiga

  • Thanks for your reply Mr Pardeep. the solution you have given me is too simple for anybody even for me, please read my post I am asking for showing the result at the top not just showing the results.

    even thanks alot for helping,

    looking forward for a useful help.

  • Rajiv,

    since I can see Long/Lat in your table I just hope you have some kind of distance function too:

    select storeID from Storemaster where

    order by distance(user.position, store.long, store.lat)

    if you have no such function yet it might be useful to write one yourself since you might be using it more often anyway.

    another option would be a distance function on zip code.

    Juliane

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply