[Phpwm] incrementing values during an update

alan dunn alan at dunns.co.uk
Wed Sep 16 15:07:57 UTC 2009


sorry, I didn't make it clear devcount is initially null in each row. So 
the value in row 1 becomes 1, in row 2, 2 etc.

phil at infolinkelectronics.co.uk wrote:
>
>
>   
>> -----Original Message-----
>> From: phpwm-bounces at mailman.lug.org.uk
>> [mailto:phpwm-bounces at mailman.lug.org.uk]On Behalf Of alan dunn
>> Sent: 16 September 2009 15:39
>> To: phpwm
>> Subject: [Phpwm] incrementing values during an update
>>
>>
>> I want to update a sub-set of records in a sql table. three of the 
>> values are fixed.
>>
>> 'devcount' I want to increment starting from 1 each time the query is 
>> run for a new $q_batch:
>>
>> UPDATE tblprintq SET q_printed = 'A', printer = '$printer', conbatch = 
>> $condbatch, devcount = ??????
>>  WHERE q_batch = $q_batch
>>  AND q_printed = 'N'
>>
>> I can do it by doing a SELECT to get the row ID, then incrementing a 
>> counter, then running an UPDATE on row ID, but is there a way of doing 
>> this within the query?
>>
>> Thanks, alan dunn
>>     
>
>
> SET devcount=devcount+1 
>
> Regards,
>
> Phil Beynon
> Sales & Operations Director
>
> ** Infolink Electronic Systems Ltd.
> ** S/W Birmingham's Longest Established ISV & VAR
> ** http://www.infolinkelectronics.co.uk
> ** Professional Web 2.0 Design & Advanced Hosting Platforms
> ** http://www.coeus-computica.co.uk
> ** Affordable Knowledgebase Solutions
> ** Contact: Sales at infolinkelectronics.co.uk
> ** Tel / Fax 0121 441 3558
> _______________________________________________
> Phpwm mailing list
> Phpwm at mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/phpwm
>   



More information about the Phpwm mailing list