Menu


How to increment the values of a field already in the database

Let suppose you have a table with some empty title fields and you want to alter them to have values like title1, title2, title3, title4 ... and so on

So if you want to increment the value of a field already in database you could use this MySQL query:


~~#FF0000:
SET @count=0;

update table set title = (SELECT CONCAT('title',@count:=@count + 1)) where title='';
~~


MySQL categories


MySQL installation? MySQL configuration? MySQL Howtos MySQL troubleshooting?

Back to > Programming





Google Search

 
www.lacisoft.com
WWW
2009-2011 (c) Lacisoft.com