count word

Codes here !

Moderators: macek, egami, gesf

tamparinn
New php-forum User
New php-forum User
Posts: 1
Joined: Tue May 15, 2012 8:42 pm

count word

Postby tamparinn » Tue May 15, 2012 10:09 pm

how can i count SUM from this sql statement

Code: Select all

SUM( LENGTH(message) - LENGTH(REPLACE(message, ' ', ''))+1) AS sum
FROM mdl_forum_posts WHERE userid = 29254
AND created>=1329692400 and created<=1339279200
Group by message
HAVING sum>=30

User avatar
Nullsig
php-forum Fan User
php-forum Fan User
Posts: 981
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI

Re: count word

Postby Nullsig » Thu May 17, 2012 4:52 am

To Count the number of records found you would just select a second variable "COUNT(*) from the result set.

Code: Select all

    SELECT COUNT(*) AS count, SUM( LENGTH(message) - LENGTH(REPLACE(message, ' ', ''))+1) AS sum
    FROM mdl_forum_posts WHERE userid = 29254
    AND created>=1329692400 and created<=1339279200
    Group by message
    HAVING sum>=30



Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 1 guest