How do I append a character to all items `purchase_id’ here is a manual example of what I want…
SELECT *
FROM `loadable_link`
WHERE `product_sku` = '2101-R'
ORDER BY `customer_id` DESC
Then select from purchased_id and append a ‘0’ to all purchased ID’s
UPDATE `loadable_link` SET `purchased_id` = '11165690'
WHERE `loadable_link`.`purchased_id` = 1116569;
2
Answers
This can be achieved in one
UPDATE
query, take the original value of each row andCONCAT()
to append a0
to the end of the existingpurchase_id
.You can update the table according to the condition in the original
select
statement.If
purchase_id
is a number, you can multiply it by 10:If
purchase_id
is a string, you can concatenate a0
to it: