简体   繁体   English

SQL查询比较(用作变量)

[英]SQL Query comparison (Use as variable)

I have two queries: 我有两个问题:

SELECT * FROM postcodelatlng, shops WHERE shops.postcode=postcodelatlng.postcode;

SELECT * FROM postcodelatlng, tesco WHERE tesco.postcode=postcodelatlng.postcode;

idea is that I would like to use lat and lng from first query and use it as variable as lat1 and lng1 我的想法是,我想从第一个查询中使用latlng ,并将其用作lat1和lng1等变量

and the take second query and use the same way to get lat2 and lng2 并采取第二个查询并使用相同的方式来获取lat2和lng2

Finally i should have like ($lat1, $lng1, $lat2, $lng2) (Start point vs End point) 最后我应该喜欢($ lat1,$ lng1,$ lat2,$ lng2)(起点与终点)

I believe you are looking sth like: 我相信你看起来像是:

SELECT *
FROM postcodelatlng
INNER JOIN tesco ON tesco.postcode = postcodelatlng.postcode
WHERE postcodelatlng.lat IN (
        SELECT lat
        FROM postcodelatlng
        INNER JOIN shops
        WHERE shops.postcode = postcodelatlng.postcode
        )
    AND postcodelatlng.lng IN (
        SELECT lng
        FROM postcodelatlng
        INNER JOIN shops
        WHERE shops.postcode = postcodelatlng.postcode
        )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM