Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 30th, 2012  |  syntax: None  |  size: 0.83 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Query to obtain number of occurrence of a given word in a database table
  2. SELECT
  3.  users.username AS username,
  4.  round(sum((LENGTH(comments.comment) - LENGTH(REPLACE(LOWER(comments.comment),"one", ""))) / LENGTH("one")), 0) AS count
  5. FROM users
  6.  INNER JOIN comments ON comments.uid = users.id
  7. GROUP BY users.id
  8. ORDER BY count DESC;
  9.        
  10. SELECT
  11.  users.username AS username,
  12.  round(sum((LENGTH(comments.comment) - LENGTH(REPLACE(LOWER(comments.comment),"one", ""))) / LENGTH("one")), 0) AS count
  13. FROM users
  14.  INNER JOIN comments ON comments.uid = users.id
  15. GROUP BY users.id
  16. ORDER BY count DESC;
  17.        
  18. SELECT
  19.  users.username AS username,
  20.  round(sum((LENGTH(comments.comment) - LENGTH(REPLACE(LOWER(comments.comment),"one", ""))) / LENGTH("one")), 0) AS count
  21. FROM users
  22.  INNER JOIN comments ON comments.uid = users.id
  23. GROUP BY users.id
  24. ORDER BY count DESC;