Michael McTernan said: > > I'm using MySQL 4.0.15-standard-log, on RedHat 9.0 with InnoDb tables. > > Essentially I have two tables, one table is a list of integers, > while the second is a table of integer pairs. e.g. > > +---+ +-----+-----+ > | A | | B.x | B.y | > +---+ +-----+-----+ > | 1 | | 1 | 5 | > | 2 | | 3 | 6 | > | 3 | +-----+-----+ > | 4 | > +---+ > > What I want to do is form a temporary table containing A, but then > with each value in A that matches B.x substituted for B.y. e.g. the > desired result from the example would be a new table: > > +---+ > | T | > +---+ > | 5 | > | 2 | > | 6 | > | 4 | > +---+
Why all the locks, temp tables and updates? You can just do: SELECT CASE WHEN B.y IS NULL THEN A.x ELSE B.y END AS newX FROM A LEFT JOIN B ON A.x = B.x Jochem -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]