EDIT
After removing my silly mistake of INTO (I was working with INSERTS and just keep going) the error below is showing. Still not working:
Affected rows: 0
[Err] 1093 - You can't specify target table 'tbl' for update in FROM clause
I'm trying to create an update where I select all the previous data in the column, add a complementary string and save it as new data. The code is below (with the error)
Using only the select, the result:
set @id = 3;
SELECT tbl_alias.string_id
FROM tbl as tbl_alias
WHERE id = @id
-- the output `3,10,8,9,4,1,7,11,5,2,6,12`
I also tried with this query (the output is what I want)
SELECT CONCAT((
SELECT tbl_alias.string_id
FROM tbl as tbl_alias
WHERE id = @id
),',13,14,15,16') AS X
-- the output `3,10,8,9,4,1,7,11,5,2,6,12,13,14,15,16`
But after replacing the select below. It brings the same error.
The query
set @id = 3;
UPDATE INTO tbl
SET string_id =
CONCAT((
SELECT tbl_alias.string_id
FROM tbl as tbl_alias
WHERE id = @id
),',13,14,15,16') WHERE id = @id;
The error
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' INTO tbl SET string_id = CONCAT(( SELECT tbl_alias.string_id ' at line 1
It's probably the CONCAT together with SELECT. But I didn't find the solution...
INTO