How to use a value from the same column in a new insert
I have an SQL statement which inserts numerous rows of data from an array (in PHP).
The data is updated daily with new values and assigned a new report_id.
there is a field labelled 'hrs_offset' in the same table (ReportData) which I want to carry across into this statement - so basically, if the report_id = 50 and the last report_id = 45, I want to copy across all the values from ReportData.hrs_offset WHERE report_id = 45 AND tech=tech.
Is this achievable? Or should I just get the values in a separate statement and load them into the PHP array?
INSERT INTO ReportData
(report_id, line_type, tech, name, rate, open_wip, clock_hrs, close_wip, avail_hrs, sold_hrs, sold_amt, cost_hrs, cost_amt, labour_gross, margin, docs, unprod_hrs, sold_avail, clock_status)
('".$this->reportID."', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";