mysql - How to update table with subselect -
i trying join output subselect fields in update table. can't right using mysql.
any idea how correctly?
update instrumentdailyinfo info set info.vwap = (select t1.vwap instrumentday t1 join (select date(tradedate) date_date, stockname, min(tradedate) min_date instrumentday group date_date , stockname) t2 on t1.tradedate = t2.min_date , t1.stockname = t2.stockname order t1.tradedate , t1.stockname asc) t1.tradedate = info.tradedate , t1.stockname = info.stockname select `instrumentdailyinfo`.`id`, `instrumentdailyinfo`.`closeprice`, `instrumentdailyinfo`.`highvalue`, `instrumentdailyinfo`.`lowvalue`, `instrumentdailyinfo`.`startprice`, `instrumentdailyinfo`.`stockname`, `instrumentdailyinfo`.`tradedate` `instrumentdailyinfo`; select `instrumentday`.`id`, `instrumentday`.`stockname`, `instrumentday`.`tradedate`, `instrumentday`.`vwap` `simplegrowth`.`instrumentday`;
update instrumentdailyinfo info join (select t1.vwap,t1.tradedate tradedate,t2.stockname stockname instrumentday t1 join (select date(tradedate) date_date, stockname, min(tradedate) min_date instrumentday group date_date , stockname) t2 on t1.tradedate = t2.min_date , t1.stockname = t2.stockname order t1.tradedate , t1.stockname asc)x on x.tradedate = info.tradedate , x.stockname = info.stockname set info.vwap= x.vwap
something if have joining column between main table , x sub query.
Comments
Post a Comment