0
我試圖運行此查詢:MySQL的更新內加入別名
UPDATE anothertable
INNER JOIN (SELECT *,
LEAST(table1.from_price, table2.from_price, table3.from_price) AS cheapestPrice
FROM (SELECT * FROM table1 v WHERE hotelid >= 1
UNION
SELECT * FROM table2 c WHERE hotelid >= 1
UNION
SELECT * FROM table3 k WHERE hotelid >= 1) AS temp
GROUP BY temp.hotelid, temp.country) AS i ON anothertable.id = i.hotelid
AND anothertable.country = i.country
SET price = i.cheapestPrice,
op = i.to
但是我不能讓LEAST
函數可以訪問一個名爲「from_price」字段。
想法?
'i.to'在缺少quert – RichardTheKiwi 2011-02-24 18:12:22
@Richard又名cyberkiwi - 你的意思是不是最後一行其他? – Thomas 2011-02-24 18:24:23
我的意思是你的查詢會因爲它而失敗。它指什麼 – RichardTheKiwi 2011-02-24 18:25:21