Results 1 to 5 of 5

Thread: SQL 'UPDATE' Statement Question

  1. #1

    Thread Starter
    Fanatic Member rudvs2's Avatar
    Join Date
    Mar 2001
    Location
    NZ
    Posts
    935

    SQL 'UPDATE' Statement Question

    Hey all.

    I working with a sql database. I have to Tables that contain data on a customer. I am using a left outer join query to retrieve and view a complete data set on the customer. My question is when Iam modifying customer details in some instances i need to update information in both tables. Is there a syntax for doing this at the same time eg

    UPDATE MYTABLE LEFT OUTER JOIN MYOTHERTABLE SET BLAH, BLAH WHERE BLAHBLAH = 'BLEH'

    would a statement like that work?

    I have tried it and get errors I cant seem to find any documentation on doing joined table updates

    any help would be appreciated thanks

  2. #2
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    No i dont think it will work.

    Look into:

    Unique Table and Resync commands.

    e.g:
    rs.Properties("Unique Table") =
    rs.Properties("Resync Command") =

    then you should be able to use rs.update i think.

    good luck
    b

  3. #3
    Addicted Member
    Join Date
    Jun 2002
    Location
    Brugge, Belgium
    Posts
    208
    I've just tried this in an access database and it works.

    UPDATE tabel1 LEFT JOIN tabel2 ON tabel1.ID = tabel2.ID SET tabel1.a = "z";

    As you can see you have to specify on what field to join and specify which table.field you update.

  4. #4
    Fanatic Member vb_dba's Avatar
    Join Date
    Jun 2001
    Location
    Somewhere aloft between the real world and insanity
    Posts
    1,016
    I use a statement similar to the following for SQL Server:
    Code:
    Update myTable
    Set Field1 = 'Test'
    From myTable Inner Join yourTable on myTable.ID = yourTable.ID
    Chris

    Master Of My Domain
    Got A Question? Look Here First

  5. #5
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    I usually use begintrans and committrans, with two updates in between them.

    That way, if one fails, no data is changed.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

Posting Permissions

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



Click Here to Expand Forum to Full Width