I am inserting records from one table into another table using the select statement. The inserted table contains a new field, which should be increased by one in each update, but should not be an automatic increase field, since the number must start again for each group of update records. If the selected select statement selects 42 records, the new table will have a field that is incremented by 1 for each record, starting with one. The next group should have this field at 1 again, and then increment for each record that has been selected. Is it possible to do this? I'm having trouble finding the syntax to use, since most of my search just finds results about auto-increment keys.
INSERT into images (filename, imgpath, imagenumber)
SELECT filename, imgpath, 1+
FROM old_images
WHERE event_id = 20
This is a simple example of tables, but I wonder if there is a way to increase what fits in the imagenumber field in the image table directly in mySql.
source
share