Results 1 to 3 of 3

Thread: Update Query

  1. #1
    Join Date
    Apr 2004
    Location
    Melbourne
    Posts
    144

    Unanswered: Update Query

    table1
    (directoryid, firstname, lastname, extension, phonenumber)

    table2
    (directoryid, firstname, lastname, extension, phonenumber)

    table2 is the latest table with updates, some of the fields in the extension field are nulls. i want to update table1.extension to table2.phonenumber based on the primary key directoryid

    update table1
    set table1.extension = table2.phonenumber
    INNER JOIN table2
    on
    table1.directoryid = table2.directoryid
    where table1.extension = '' or table1.extension is NULL.


    Is my query correct ?

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    That's hard to say....what's the requirement?

    Don't you have access to query analyzer?

    Did you read the sticky at the top of the forum?
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Your query looks fine to me. As always, make sure you have backups of your database.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

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