Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2004
    Location
    Dallas, TX
    Posts
    77

    Unanswered: question for update query

    If I have tb1 with col1, col2, col3,
    Tbl2 with col2, col4, col5
    Col2 in tbl2 is FK of col2 in tbl2

    I want to update col5 in tbl2 for all rows which tbl1.col3 = xxx

    I wrote query like this:

    1. Update tbl2 set col5 = ddd where tbl1.col2 = tbl2.col2 and tbl1.col3 = xxx

    2. Update tbl2 set col5 = ddd from tbl1 inner join tbl2 on tbl1.col2 = tbl2.col2 where tbl1.col3 = xxx

    for first query, it give error for no value or parameter,
    for second query, it give error for syntax error.

    Anybody have idea how to write this query??
    Appreciate for your help

  2. #2
    Join Date
    Sep 2004
    Location
    Reston, VA
    Posts
    86
    Try switching it around like this:

    UPDATE tbl1 INNER JOIN tbl2 ON tbl1.col2 = tbl2.col2 SET tbl2.col5 = "ddd"
    WHERE tbl1.col3="xxx"

  3. #3
    Join Date
    Sep 2004
    Location
    Dallas, TX
    Posts
    77
    BummerJeff

    thanks a lot. it works fine now.
    appreciate for your help

    Huela

Posting Permissions

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