Created
March 12, 2013 10:50
-
-
Save Freeaqingme/5141972 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; ERROR 1093 (HY000) at line 14: You can't specify target table 'brands' for update in FROM clause | |
UPDATE accounts a LEFT JOIN brands b on b.id = a.brand_id set brand_id = ( | |
SELECT b1.id | |
FROM brands b1 LEFT OUTER JOIN brands b2 | |
ON ( | |
b1.code = b2.code AND b1.id > b2.id) | |
where b2.id is null and UPPER(b1.code) = UPPER(b.code) | |
) | |
; #1093 - You can't specify target table 'a' for update in FROM clause | |
UPDATE accounts a set brand_id = ( | |
SELECT id FROM | |
(SELECT b1.id | |
FROM brands b1 | |
LEFT OUTER JOIN brands b2 ON (b1.code = b2.code AND b1.id > b2.id) | |
LEFT JOIN accounts a2 ON a.id = a2.id | |
LEFT JOIN brands b ON a2.brand_id = b.id | |
where b2.id is null and UPPER(b1.code) = UPPER(b.code)) as tmp | |
) | |
; #1054 - Unknown column 'a.brand_id' in 'on clause' | |
UPDATE accounts a set brand_id = ( | |
SELECT id FROM | |
(SELECT b1.id | |
FROM brands b1 | |
LEFT OUTER JOIN brands b2 ON (b1.code = b2.code AND b1.id > b2.id) | |
LEFT JOIN brands b ON a.brand_id = b.id | |
where b2.id is null and UPPER(b1.code) = UPPER(b.code)) as tmp | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment