Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2006
    Posts
    87

    Unanswered: problem with update query

    HI all need help on this query.. I am updating two fields in info table 1ID and 2ID based on another table in a database. the last WHERE clause is the ID of the info table that points to that specific record..... below is my sql but doesn't work

    UPDATE info
    SET 1ID=(SELECT 1ID
    FROM DBname.dbowner.persons
    WHERE name="name")
    AND 2ID=(SELECT 2ID FROM DBname.dbowner.persons
    WHERE name="name")
    WHERE ID='100'

    thanks

  2. #2
    Join Date
    Aug 2007
    Posts
    17
    UPDATE info
    set 1ID = b.1ID,
    2ID = b.2ID
    from info a, DBname.dbowner.persons b
    where a.id = '100'
    and b.name = 'name'

  3. #3
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Yeah, that code satisfies the poster's request, but I have to wonder if the poster's request is really satisfying the poster's needs...

    It is an odd and unusual query.

    Alexiop, is there no link or join between these tables? Are you updating all the "id=100" records to the same values?
    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
  •