Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Basically, if I understand well you want to sort by the closest zone.</p> <p>So maybe you should translate your ids 1, 2, 3, 4, 5 into coordinates like:</p> <ul> <li>1 North: x:0, y:1</li> <li>2 East: x:1, y:0</li> <li>3 West: x:-1, y:0</li> <li>4 South: x:0, y:-1</li> <li>5 Center: x:0, y:0</li> </ul> <p>Then sort them by distance calculated.</p> <hr> <p>Example: You are located in West and you have restaurants located in West, North, South and Central</p> <p>If you have the coordinates you can calculate the distance then sort your results:</p> <ul> <li>West restaurant distance 0</li> <li>North restaurant distance 1.2xxx (something like that)</li> <li>South restaurant distance 1.2xxx (something like that)</li> <li>Central restaurant distance 1</li> </ul> <hr> <p>So, assuming you have implemented the functions <code>GET_DISTANCE()</code> &amp; <code>GET_COORD()</code> you would have</p> <pre class="lang-sql prettyprint-override"><code>SELECT menu_item.restaurant_id , menu_item.price , localities.locality_name , restaurant_information.restaurant_name , restaurant_information.restaurant_address , restaurant_information.is_halal , restaurant_information.cuisine , restaurant_information.city , restaurant_information.pincode FROM menu_item JOIN restaurant_information ON (menu_item.restaurant_id = restaurant_information.restaurant_id) JOIN localities ON (restaurant_information.locality_id = localities.locality_id) WHERE TRUE AND menu_item.dish_id = $dish_id AND menu_item.is_active = 1 AND restaurant_information.is_active = 1 ORDER BY GET_DISTANCE( GET_COORD($my_position) , GET_COORD(restaurant_information.locality_id) ) ; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload