I want to extract unique minlat, minlng based on city and country then want to find all id which have this pair I mean something like
select id from spots
where (minlat,minlng) in
(select s.minlat, s.minlng from spots s, spot_cards sc
where sc.spot_id=s.id and sc.country="italy"
and
(sc.city="perugia" or sc.locality="perugia" or sc.sublocality="perugia")
);
Structure of spots table is:
+----+-----------+-----------+
| id | minlat | minlng |
+----+-----------+-----------+
I created spot_cards table structure as
+---------+-------------+-------------+---------+--------+
| spot_id | sublocality | locality | country | city |
+---------+-------------+-------------+---------+--------+
by executing below query
insert into spot_cards(spot_id)
select id from spots
group by minlat,minlng
order by id
Any help is appreciated.