The problem of sorting goods by merchant's location

Project is an application for local merchants to issue coupons
the current demand is to sort the coupons according to the distance from the merchant

problems encountered:
merchants can create multiple coupons. The coupons do not have a separate location and can only take the location of the merchant to which they belong. But if all the merchants take the location, it is possible that the first few coupons are all the same merchant. How to solve this situation?

May.11,2022

there is no way to sort and display coupons directly.
you show that merchants with coupons are sorted by merchants


try to provide two ideas for reference.
1, join the merchants and coupons directly, and display them according to the merchant dimension, so that they can be duplicated.
2, in addition, think about the multi-dimensions of coupons, according to user interests, access, and so on, so I don't think there is a need to think about repetition. For example, the two most popular videos belong to the same blogger, so do you want to remove one?


either the front end only shows the order of the merchant, click and then list the merchant's coupons;
or the same merchant's coupons according to the remaining quantity / quota /. Such latitude (by business) to do the second ranking to take the first place.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b9feac-2f4de.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b9feac-2f4de.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?