I have a database that contains 2 tables:
- Businesses.
- Coupons
Every row in Businesses
have the following fields:
{id
, details
, image
, name
, location_x
, location_y
},
where location_x
and location_y
is the latitue
and longitue
coordiates of google maps.
In the Coupons
Table, every row have the following fields:
{id
, business_id
, image
, details
, goneDate
, goneHour
}.
id
is the coupon id
,
and business_id
is the id
of the business
that this coupon belongs to.
My question:
By quering Coupons
, how can I get all the coupons that their owner business location radius is less then 10km
from a given coordinates?
or in other words, it's someone like that:
how to take every coupons business id , then go to the business table , and check if that business id location's radius is less than 10km from given location?
I think it related with inner join
, not sure.
I'm working in hibernate framework in Java.
Please help me, thanks in advance!