
Untitled
By: a guest on
Apr 30th, 2012 | syntax:
None | size: 0.83 KB | hits: 14 | expires: Never
Query to obtain number of occurrence of a given word in a database table
SELECT
users.username AS username,
round(sum((LENGTH(comments.comment) - LENGTH(REPLACE(LOWER(comments.comment),"one", ""))) / LENGTH("one")), 0) AS count
FROM users
INNER JOIN comments ON comments.uid = users.id
GROUP BY users.id
ORDER BY count DESC;
SELECT
users.username AS username,
round(sum((LENGTH(comments.comment) - LENGTH(REPLACE(LOWER(comments.comment),"one", ""))) / LENGTH("one")), 0) AS count
FROM users
INNER JOIN comments ON comments.uid = users.id
GROUP BY users.id
ORDER BY count DESC;
SELECT
users.username AS username,
round(sum((LENGTH(comments.comment) - LENGTH(REPLACE(LOWER(comments.comment),"one", ""))) / LENGTH("one")), 0) AS count
FROM users
INNER JOIN comments ON comments.uid = users.id
GROUP BY users.id
ORDER BY count DESC;