Results 1 to 2 of 2

Thread: updating count fields

  1. #1
    Join Date
    Dec 2002
    Location
    Napoli, ITALY
    Posts
    1

    Unhappy updating count fields

    I have to build a database of firms that can have more than one address. It is formed by two Tables:

    Table1 Firms

    Fields

    FirmID Firm name Number_of_sites

    Table2 Addresses

    SiteID FirmID SiteAddress

    Do you know if I can update the Number_of_sites field by using an UPDATE query with a count on the fields of the second table joined to the ones of the first?

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    update Firm
    set Number_of_sites = (select count(*)
    from Addresses
    where FirmID = Firm.FirmID)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •