【问题标题】:SQL Query comparison (Use as variable)SQL 查询比较(用作变量)
【发布时间】:2017-02-13 15:13:13
【问题描述】:

我有两个疑问:

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

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

想法是我想从第一个查询中使用 latlng 并将其用作 lat1 和 lng1 的变量

和采取第二次查询并使用相同的方式获取lat2和lng2

最后我应该喜欢 ($lat1, $lng1, $lat2, $lng2) (起点与终点)

【问题讨论】:

  • 编辑您的问题并提供示例数据和所需的结果。

标签: php mysql sql


【解决方案1】:

我相信你看起来像:

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
        )

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-09-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多