UPDATE table1
LEFT JOIN table2 ON table1.ColB = table2.CodeB
SET table1.ColA = table2.CodeA
WHERE table2.CodeB IS NOT NULL;
Iman wrote:
Anyone knows what's the equivalent statement I can use in mysql: update table1 set colA = (select codeA from table2 where codeB=table1.colB) Thanks and best regards....
Anyone knows what's the equivalent statement I can use in mysql:
update table1 set colA = (select codeA from table2 where
codeB=table1.colB)
Thanks and best regards.
UPDATE table1
LEFT JOIN table2 ON table1.ColB = table2.CodeB
SET table1.ColA = table2.CodeA
WHERE table2.CodeB IS NOT NULL;
Iman wrote:
UPDATE table1
LEFT JOIN table2 ON table1.ColB = table2.CodeB
SET table1.ColA = table2.CodeA
WHERE table2.CodeB IS NOT NULL;
Iman wrote:
Hi Peter,
Appreciate if you can let me know which version of mysql that support
your sql statement.
com wrote: [/ref]
In article <googlegroups.com>,
says...
>
> UPDATE table1
> LEFT JOIN table2 ON table1.ColB = table2.CodeB
> SET table1.ColA = table2.CodeA
> WHERE table2.CodeB IS NOT NULL;[/ref]
Instead of checking table2.CodeB IS NOT NULL;, why not just use an INNER
JOIN?
UPDATE table1
INNER JOIN table2 ON table1.colB = table2.CodeB
SET table1.ColA = table2.CodeA;
--
PleegWat
Remove caps to reply
In article <googlegroups.com>, Iman
says... [/ref][/ref]
Multi-table updates are supported starting MySQL 4.0.4
--
PleegWat
Remove caps to reply
Bookmarks