Help in update query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ScarletPimpernal
    New Member
    • Mar 2007
    • 39

    Help in update query

    Hi friends,


    table-1
    -------
    id--name--value
    -------------
    1--'Test'--'Test'
    2--'Testing'--'Testing'


    table-2
    -------
    id--name--value
    ---------------
    1--'no'--'no'
    2--'yes'--'yes' -- Want to update this row as per the values from the table-1 for the id =2 from table-1

    How can i do this?


    Thanks,
    Scarlet
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    Want to update this row as per the values from the table-1 for the id =2 from table-1

    How can i do this?
    You can start by clarifying your question

    Comment

    • masdi2t
      New Member
      • Jul 2006
      • 37

      #3
      Originally posted by ScarletPimperna l
      Hi friends,
      table-1
      -------
      id--name--value
      -------------
      1--'Test'--'Test'
      2--'Testing'--'Testing'

      table-2
      -------
      id--name--value
      ---------------
      1--'no'--'no'
      2--'yes'--'yes' -- Want to update this row as per the values from the table-1 for the id =2 from table-1
      try this
      UPDATE table-2, table-1 SET table-2.value = table-1.value
      WHERE table-1.id=table-2.id AND table-2.id=2;

      Comment

      • pradeep kaltari
        Recognized Expert New Member
        • May 2007
        • 102

        #4
        Originally posted by ScarletPimperna l
        Hi friends,


        table-1
        -------
        id--name--value
        -------------
        1--'Test'--'Test'
        2--'Testing'--'Testing'


        table-2
        -------
        id--name--value
        ---------------
        1--'no'--'no'
        2--'yes'--'yes' -- Want to update this row as per the values from the table-1 for the id =2 from table-1

        How can i do this?


        Thanks,
        Scarlet



        You can also use this:
        UPDATE TABLE-2 B
        LEFT OUTER JOIN TABLE-1 A ON A.ID=B.ID WHERE A.ID=2

        Comment

        Working...