update companystatistic  
set ReferencePrice = (select ClosedPrice from companystatistic WHERE CompanyID= 310 and ResultedDate = CURDATE() - 1) 
where ResultedDate = CURDATE() 
and CompanyID= 310

I have a same code. But it's not work..
help me..!
thanks all

What is not working ?
Are you getting any error ?

Check if your sub query returns any record.

hi kayak_186,
whats output you getting?

hi, anand01, debasisdas.

I'm getting error:
Error Code : 1093
You can't specify target table 'companystatistic' for update in FROM clause

thanks all,
I fixed problem..

update companystatistic
set ReferencePrice = ( select ClosedPrice
from (Select * from companystatistic) as X
WHERE CompanyID= 310 and ResultedDate = CURDATE() - 1
)
where ResultedDate = CURDATE()
and CompanyID= 310

hihi.. It's working

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.