首页 > 查询附近的人的SQL语句。这个and条件这样写正确不?就是把and条件扩起来

查询附近的人的SQL语句。这个and条件这样写正确不?就是把and条件扩起来

select    userid,username,avatarSmall,latitude,longitude from tbl_myr_user,tbl_myr_refresh  where 

tbl_myr_user.userid=tbl_myr_refresh.userid and(
           geohash=:geohash1 
        or geohash=:geohash2
        or geohash=:geohash3
        or geohash=:geohash4
        or geohash=:geohash5
        or geohash=:geohash6
        or geohash=:geohash7
        or geohash=:geohash8
        or geohash=:geohash9


)

SELECT    `userid`, `username`, `avatarSmall`, `latitude`, `longitude`
FROM      `tbl_myr_user`
LEFT JOIN `tbl_myr_refresh`
ON tbl_myr_user.userid = tbl_myr_refresh.userid
WHERE `geohash` IN (geohash1, geohash2, geohash3, geohash4, geohash5, geohash6, geohash7, geohash8, geohash9)

不太清楚你这个多表查询是否需要用到JOIN,我就是来吐槽下那个geohash的。

【热门文章】
【热门文章】