Update Field Question

  • I have this query which is correct or so far so good:

    SELECT dbo.tblContact.ContactID, dbo.tblContact.FirstName, dbo.tblContact.MiddleName,

        dbo.tblContact.LastName,

        dbo.tblMemberContact.PrimaryContact,

        dbo.tblMemberContact.Board

    FROM dbo.tblMemberContact INNER JOIN

        dbo.tblContact ON

        dbo.tblMemberContact.ContactId = dbo.tblContact.ContactID

    WHERE (dbo.tblMemberContact.PrimaryContact = 1)AND

    (dbo.tblContact.LastName = 'Smith')

     

    In tblMemberContact there is a Field named Board, which is type Bit, I would like to update that field to 'TRUE' where the Contact ID field is = '20'

    I am a little lost; This is an SQL Server 2000 DB; thanks

  • update the whole table for the field id = 20 or the field id = 20 and is in this query?

  • yes u are correct ContactId = 20 (as an example)

  • Still not sure of what you want...

    Update tblMemberContact set Board = 1 /*true*/ where Contact_ID = 20

    This will update all the rows of the table with a contact_id of 20. This will NOT TAKE into consideration the filters that the joins may have created. Is this query what you need?

  • Thanks but I got it too work, although not the best way I am sure;  I used 2 queries and did them one at a time

    first I looked up the contact id based upon the above posted query.  Then I ran this update query:

    UPDATE tblMemberContact

        SET tblMemberContact.Board = 1

        WHERE tblMemberContact.ContactId ='71'

     

    It worked fine one at a time, I have a group of 16, and didn't know how to update that field for the whole group, but live and learn.

    thanks Victoria

  • Here's an option :

    UPDATE tblMemberContact

    SET tblMemberContact.Board = 1

    WHERE tblMemberContact.ContactId in (

    SELECT dbo.tblContact.ContactID

    FROM dbo.tblMemberContact INNER JOIN

    dbo.tblContact ON

    dbo.tblMemberContact.ContactId = dbo.tblContact.ContactID

    WHERE (dbo.tblMemberContact.PrimaryContact = 1) AND

    (dbo.tblContact.LastName = 'Smith')

    )

    Is this what you wanted?

  • In all honesty, I am not sure if that is what i want, but I am willing to try it...

    I am really a newbie at starting to code and query this db, this was the first time i attempted to update a group of records.  But i wanted to create a group, then query the db and return that group to a webpage.  So creating the group was the first step.  I appreciate your help, and am sorry I am not more knowledgeable.

    Victoria

  • We all started somewhere... near the bottom .

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply