Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

count word

Codes here !

Moderators: macek, egami, gesf

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
tamparinn
New php-forum User
New php-forum User
 
Posts: 1
Joined: Tue May 15, 2012 8:42 pm

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

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


Return to mySQL & php coding

Who is online

Users browsing this forum: Google [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.