Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: ambiguous col
03-26-2013, 01:24 PM #1
- Join Date
- Dec 2005
- Thanked 77 Times in 77 Posts
id is key
insert into test select t1.id,@variable := t1.col from test t1 on duplicate key update col = col + @variable
insert into test t select t1.id,t1.col from test t1 on duplicate key update t.col = t.col + t1.col
03-26-2013, 09:21 PM #2
Yes, I got that, too.
But here's a sneaky way around it:
Code: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;
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.