Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

How can i update data of current row with selecting data of previous row in php mysql. I have tried following query but it showing me error.

update sales_tracking
set sales_tracking.opening_units = (
  select sales_tracking.closing_units
  from sales_tracking
  where sales_tracking.month='05'
) where sales_tracking.month='06';
share|improve this question
Which error is "it showing"? –  Colin 't Hart Oct 15 '13 at 12:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.