I try swap 3 columns in my table. I try this :
DELIMITER $$
CREATE PROCEDURE px()
BEGIN
DECLARE temp VARCHAR(20);
update `idsaccess` set
temp = referer,
referer = size_var,
size_var = agent,
agent = temp
WHERE agent like '%210%' ;
END $$
CALL p
It don't work. It give me that error: Unknown column 'temp' in 'field list'
I do not understand that: temp is varchar value not a column. I also try remove DECLARE and PROCEDURE and just set variable with @. Like this:
set @temp = '';
update `idsaccess`
set @temp = referer,
referer = size_var,
size_var = agent
agent = @temp
WHERE agent like '%210%'
It don't work either. It give me. You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax
. Any idea what is wrong in my code ? And to avoid misunderstanding I don't want move columns. I just want swap SOME rows (WHERE agent like '%210%') from one column to another.