[英]SQL Query comparison (Use as variable)
我有兩個問題:
SELECT * FROM postcodelatlng, shops WHERE shops.postcode=postcodelatlng.postcode;
SELECT * FROM postcodelatlng, tesco WHERE tesco.postcode=postcodelatlng.postcode;
我的想法是,我想從第一個查詢中使用lat和lng ,並將其用作lat1和lng1等變量
並采取第二個查詢並使用相同的方式來獲取lat2和lng2
最后我應該喜歡($ lat1,$ lng1,$ lat2,$ lng2)(起點與終點)
我相信你看起來像是:
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.