I have the following table:
| ID | url |
|-----|---------------------------------------|
| 1 | item/ldksfnsldknfsdfioj34j30h34i034 |
| 2 | item/09d0s8ysd8c0dsjc89shd7csd9chs9 |
| ... | ... |
I want to apply a new method to generate the random string of characters, which is:
SELECT LEFT(UUID(), 28);
But I don't know how to write the query so that it does an UPDATE on the whole column url
at once. I imagine it should be something like:
UPDATE tabla
SET url = ('items/' (SELECT LEFT(UUID(), 28));
But I get error:
syntax to use near '(SELECT LEFT(UUID(), 28))' at line 2
The error is because you are concatenating the strings
'items/'
andLEFT(UUID(), 28)
.Solution:
You could use
CONCAT
to concatenate the strings, like so: