mysql where跟多个字段_mysql里面有多个字段(mysql where multiple fields in)

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值