Steve - 3 things

1/ count(*) is prob safer
2/ brackets in the wrong place
3/ Semicolon?

Try

UPDATE CLIENT
SET CLIENT.CardIssuedTotal =
(SELECT COUNT(*)
FROM CARD
WHERE CLIENT.ClientNumber = CARD.ClientNumber)

Have you considered doing it in a trigger on CARD?

HTH

Neven



----- Original Message -----
From: "Steve Galyer" <[EMAIL PROTECTED]>
To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]>
Sent: Wednesday, 25 July 2001 15:47
Subject: [DUG]: SQL Update question


I have a Client table and a Card table, each client can have any number of
cards, what I am attempting to achieve is to update a field in the Client
table called CardIssuedTotal with the count of the cards associated with
that client.

I am using the following SQL statements, however I am getting an error
"Parameter CARD.CardNumber has no default value"

UPDATE CLIENT

SET CLIENT.CardIssuedTotal =

(SELECT COUNT(CARD.CardNumber)

FROM CARD

GROUP BY CARD.ClientNumber)

WHERE (CLIENT.ClientNumber = CARD.ClientNumber);

Any assistance appreciated.



Steve Galyer



---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to