MySQL Forums
Forum List  »  Newbie

Re: How efficiently update frequency of words?
Posted by: Andrzej Borucki
Date: March 11, 2023 07:59AM

My solution - two SQL queries
First update existing:

UPDATE words
INNER JOIN bwords
ON words.word = bwords.word and
words.pos = bwords.pos
SET words.count = words.count+bwords.count


second, add new words:

INSERT INTO words ( word, pos, count)
SELECT word, pos, count
FROM bwords b
WHERE
NOT EXISTS (SELECT * FROM words w
WHERE b.word = w.word and b.pos = w.pos)

Both must be in one transaction

Options: ReplyQuote


Subject
Written By
Posted
Re: How efficiently update frequency of words?
March 11, 2023 07:59AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.