Solved

PHP Mysql Syntax For Count and Select

Posted on 2011-03-21
2
282 Views
Last Modified: 2012-06-21
Hello,

 I want to count and select multiple items in a table.

 I want to select members who opened more than 15 threads in the last 15 days.

 Threadid - userid - dateline are the column names.


How can i select and list these userids?
0
Comment
Question by:mescalin
  • 2
2 Comments
 
LVL 8

Expert Comment

by:Rik-Legger
ID: 35183819
This will do:

SELECT *, COUNT(*) as num_threads FROM `table` WHERE  DATE_SUB(CURDATE(),INTERVAL 15 DAY) <= dateline  GROUP BY `userid` HAVING num_threads > 15 ORDER BY aantal DESC

Open in new window


I'm not sure what kind of value you have in dateline but let me know if this doens't work so you can give me some more detail on that field.
0
 
LVL 8

Accepted Solution

by:
Rik-Legger earned 500 total points
ID: 35183822
Correction in query:

SELECT *, COUNT(*) as num_threads FROM `table` WHERE  DATE_SUB(CURDATE(),INTERVAL 15 DAY) <= dateline  GROUP BY `userid` HAVING num_threads > 15 ORDER BY num_threads DESC

Open in new window

0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now