Solved

PHP Mysql Syntax For Count and Select

Posted on 2011-03-21
2
289 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to dynamically set the form action using jQuery.
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.

749 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