Hi David.
David Scott wrote:
I am trying to update the column CreditCode in a table extract using
data from another table CreditCodes, which has columns CreditCode and
Consumer_No.
I have been given the following sql which works on another database (not
sure which and it is late at night so I can't ring up and ask)
update extract
set CustomerCreditCode = b.CreditCode
from extract a
inner join CreditCodes b
on a.ConsumerNO = b.Consumer_No;
It looks like SQL Server or Sybase to me, but maybe other things have the same
syntax.
This gives an error in mysql:
ERROR 1064: You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near 'from extract a
inner join CreditCodes b
on a.ConsumerNO = b.Cons
Can anyone translate it into correct mysql syntax for me?
Here are two ways you can try, which may have different performance:
update extract set CustomerCreditCode
= ( select CreditCode from CreditCodes as b where extract.ConsumerNO =
b.Consumer_No);
update extract as a
inner join CreditCodes b
on a.ConsumerNO = b.Consumer_No
set a.CustomerCreditCode = b.CreditCode;
Baron
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]