Board index » delphi » Update query with sub-query

Update query with sub-query

I have two tables:

AcctType & DialBank

I want to UPDATE AcctType the field, BankName, with the value of the
field, BankName, in the DialBank table WHERE AcctType.BankID =
DialBank.BankID.

This syntax does not work.  Any help would be greatly appreciated......

UPDATE AcctType SET AcctType.BankName = DialBank.BankName WHERE
DialBank.BankName IN (SELECT DialBank.BankName WHERE AcctType.BankID =
DialBank.BankID);

Todd

--
Todd Cary
Ariste Software
t...@aristesoftware.com

 

Re:Update query with sub-query


Figured out the solution:

  Cmd := 'UPDATE AcctType SET BankName=B.BankName FROM AcctType A ' +
         'INNER JOIN DialBank B ON A.BankID=B.BankID';

--
Todd Cary
Ariste Software
t...@aristesoftware.com

Re:Update query with sub-query


Quote
"Todd Cary" <t...@aristesoftware.com> wrote in message

news:3B814F9F.ED6CD847@aristesoftware.com...

Quote
> I have two tables:

> AcctType & DialBank

> I want to UPDATE AcctType the field, BankName, with the value of the
> field, BankName, in the DialBank table WHERE AcctType.BankID =
> DialBank.BankID.

> This syntax does not work.  Any help would be greatly appreciated......

> UPDATE AcctType SET AcctType.BankName = DialBank.BankName WHERE
> DialBank.BankName IN (SELECT DialBank.BankName WHERE AcctType.BankID =
> DialBank.BankID);

> Todd

> --
> Todd Cary
> Ariste Software
> t...@aristesoftware.com

You don't appear to have a FROM clause in your subquery.

John.

Other Threads