MySQL database
Each row from article
has 0 to 10 rows in price
,
but ordNum
is empty as I added it after few years.
Is there an one-liner to set ordNum
so that each article gets values from 1
to n
for its prices?
For example, article that has 3 prices should have their ordNum
set to 1
, 2
and 3
.
The order of the prices is not important, but it would be an added value if it could be taken into account.
Articles:
CREATE TABLE `article` (
`id` INT(11) NOT NULL,
`name` TEXT NULL DEFAULT NULL
);
Prices:
CREATE TABLE `price` (
`id` INT(11) NOT NULL,
`amount` VARCHAR(24) NULL DEFAULT NULL,
`article_id` INT(11) NULL DEFAULT NULL,
`currency_id` INT(11) NULL DEFAULT NULL,
`ordNum` INT(11) NULL DEFAULT NULL
);