我試圖從更新表中的字段加入子查詢的輸出。但使用MySQL無法正確使用它。如何使用子選擇更新表
任何想法如何正確地做到這一點?
update INSTRUMENTDAILYINFO info
set
info.vWap = (SELECT
t1.vWap
FROM
INSTRUMENTDAY t1
JOIN
(SELECT
Date(tradedate) date_date,
stockName,
min(tradedate) min_date
FROM
INSTRUMENTDAY
GROUP BY date_date , stockName) t2 ON t1.tradedate = t2.min_date
AND t1.stockName = t2.stockName
order by t1.tradedate , t1.stockName asc)
where
t1.tradeDate = info.tradeDate
and t1.stockName = info.stockName
SELECT
`INSTRUMENTDAILYINFO`.`ID`,
`INSTRUMENTDAILYINFO`.`CLOSEPRICE`,
`INSTRUMENTDAILYINFO`.`HIGHVALUE`,
`INSTRUMENTDAILYINFO`.`LOWVALUE`,
`INSTRUMENTDAILYINFO`.`STARTPRICE`,
`INSTRUMENTDAILYINFO`.`STOCKNAME`,
`INSTRUMENTDAILYINFO`.`TRADEDATE`
FROM `INSTRUMENTDAILYINFO`;
SELECT
`INSTRUMENTDAY`.`ID`,
`INSTRUMENTDAY`.`STOCKNAME`,
`INSTRUMENTDAY`.`TRADEDATE`,
`INSTRUMENTDAY`.`VWAP`
FROM `SimpleGrowth`.`INSTRUMENTDAY`;
你可以創建一個小提琴嗎? – Mihai