I have a table, with 700 lines.
I would like to introduce a new field called Reference.
This field should contain a number (starting from 5000) and a prefix, like ppm.
Line 1, should contain in the field Reference the following:
ppm5001
And line 700 should be:
ppm5700
How can I do this? Some hints!
Automatic insertion
Moderator: General Moderators
Hints, hints...
In the absence of any good ideas
, perhaps you could:
1. Create the field as usual.
2. Create a loop (pseudo code here...
What I mean, loop a query using LIMIT (to update only one record) and order by ID (to get it in the correct order). Using "is null" makes sure you do not try to change a record that is allready changed. Might help (?)
In the absence of any good ideas
1. Create the field as usual.
2. Create a loop (pseudo code here...
Code: Select all
for ($i=1;$i=700;$i++) {
$insertion = 'ppm'.$i;
mysql_query("update table set NewFieldname = '$insertion' where NewFieldname is null order by id limit 1");
}