Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2007
    Posts
    130

    Unanswered: How to update one table depending on another table

    Hello ALL,

    I have the two tables;

    Code:
    t1
    DocID  Word   TitleWord  
    1         book      0
    1         read       0
    1         open       0
    
    2         computer 0
    2         book        0
    
    3         paper       0
    3         desk        0
    
    
    
    t2
    DocID   Word     Tag
    1          book      noun
    
    2          computer   noun
    I would like to update the t1.TitleWord field according to the table t2.
    Code:
    t1
    DocID  Word   TitleWord  
    1         book      1
    1         read       0
    1         open       0
    
    2         computer 1
    2         book        0
    
    3         paper       0
    3         desk        0
    I want to use the following statement
    Code:
    UPDATE t1, t2
    
      SET  
             t1.TitleWord = '1'
    WHERE
           t1.DocID = t2.DocID  AND t1.Word = t2.Word
    I wonder if this statement is correct.

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Quote Originally Posted by cy163
    ...I wonder if this statement is correct.
    I dunno
    why not try it and find out, and save the 6..12 hour delay?
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Apr 2007
    Posts
    130
    healdem, thanks.

    I have tried with this statement and it worked well. However, I am not sure. Hence, i post it here to get comments.

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    well if it works it works
    or is the question
    I've tried this, but is there a better solution?
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Feb 2008
    Location
    Bandung - Indonesia
    Posts
    15
    UPDATE t1
    SET TitleWord=1
    where DocID=1 AND Word="book"

    UPDATE t1
    SET TitleWord=1
    where DocID=2 AND Word="computer"
    Forum Informatika - Indonesian Informatics Online Community - http://if.web.id

Posting Permissions

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