CREATE TABLE IF NOT EXISTS words (word1 varchar(256), word2 varchar(256), counter int);
CREATE INDEX IF NOT EXISTS word1word2 ON words (word1, word2);
-- @select_cond
SELECT counter FROM words WHERE word1=@w1 AND word2=@w2 LIMIT 1;
-- @increment
UPDATE words SET counter=counter+1 WHERE word1=@w1 AND word2=@w2;
-- @add_new
INSERT INTO words (word1, word2, counter) VALUES(@w1, @w2, 1);
-- @count_word1
SELECT sum(counter) FROM words WHERE word1=@word LIMIT 1;
-- @select_by_word1
SELECT word2, counter FROM words WHERE word1=@word;
-- @count_all
SELECT COUNT(*) FROM words LIMIT 1;
-- @select_all_notempty
SELECT word1, word2, counter FROM words WHERE word1!='' AND word2!='' ORDER BY counter DESC LIMIT 10;
