...

View Full Version : ambiguous col



BubikolRamios
03-26-2013, 12:24 PM
id is key



insert into test
select t1.id,@variable := t1.col from test t1
on duplicate key update col = col + @variable


same with this



insert into test t
select t1.id,t1.col from test t1
on duplicate key update t.col = t.col + t1.col


SQL Error (1052): Column 'col' in field list is ambiguous

?

Old Pedant
03-26-2013, 08:21 PM
Yes, I got that, too.

But here's a sneaky way around it:


CREATE VIEW testview AS
SELECT id, col AS viewcol FROM test;

INSERT INTO test
SELECT id, viewcol FROM testview
ON DUPLICATE KEY UPDATE col = col + viewcol;



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum