0

単語を含むvarchar列があります。@variablesを動的に作成し、列の値を使用して各変数に名前を付けて、各単語の数を保持したいと思います。

//Define all variables in PHP dynamically
@word1:=0, @word2:=0;

//Select and count how many times each word exists
SELECT (@column_value:=@column_value+1) AS words FROM Data ORDER BY words

上記の「@column_value」は「@word1」..「@word2」などである必要があります。

お手伝いありがとう。

4

1 に答える 1

0

次のような通常のカウント SQL 機能を使用して単語を数えてみませんか。

SELECT word, COUNT(word) as `count`
FROM Data
GROUP BY word
ORDER BY word ASC
于 2012-09-11T13:52:12.257 に答える