Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
|
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 17th, 2008, 05:27 AM
ire ire is offline
Authorized User
 
Join Date: May 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL query for frequency-related results

Hi guys,
I need some assistance please: how do I structure a SQL command to return frequency-related results from a database. For example, if I wanted the query to return the top 5 entries in a table within specified dates. By top 5 (N), I mean the records (values) in a given table that have occurred the most within that table. Perhaps, to help you help me, if user requests for a product were entered into a table, and I wanted to find out the most requested product in the month of May or within the last 6 months, how will the SQL query be please? Thanks.
 
Old November 17th, 2008, 07:40 AM
ire ire is offline
Authorized User
 
Join Date: May 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

problem solved - solution available at http://groups.google.co.uk/group/com...e143e44?hl=en#

 
Old December 23rd, 2008, 09:24 PM
Authorized User
 
Join Date: Dec 2008
Posts: 50
Thanks: 1
Thanked 5 Times in 5 Posts
Default

Quote:
Originally Posted by ire View Post
Hi guys,
I need some assistance please: how do I structure a SQL command to return frequency-related results from a database. For example, if I wanted the query to return the top 5 entries in a table within specified dates. By top 5 (N), I mean the records (values) in a given table that have occurred the most within that table. Perhaps, to help you help me, if user requests for a product were entered into a table, and I wanted to find out the most requested product in the month of May or within the last 6 months, how will the SQL query be please? Thanks.

i had to go and find the code from my website here is the code that does what you looking for

PHP Code:
$query "SELECT SQL_CALC_FOUND_ROWS *,MATCH (title,story.desc) AGAINST ('$keyphrase') as rele FROM story WHERE MATCH (title,story.desc) AGAINST ('$keyphrase') ORDER BY rele DESC LIMIT ".(($page-1)*($resultPerPage)).",".($resultPerPage);

$result mysql_query($query) or die($query); 
in the above query by "rele" i mean relevance or frequency.

thanks
 
Old December 24th, 2008, 10:40 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Why do you give an answer
(a) a month and a half late and
(b) when the original poster says he has already solved the problem???

What was the point?
 
Old December 25th, 2008, 04:51 PM
Authorized User
 
Join Date: Dec 2008
Posts: 50
Thanks: 1
Thanked 5 Times in 5 Posts
Default

hi Old Pedant,

sorry actually i did not really check the time and did not read the other replies, i just tried to answer the question.

Thanks





Similar Threads
Thread Thread Starter Forum Replies Last Post
Edit Query Results in Results Grid druid2112 SQL Server 2005 1 June 28th, 2007 08:49 AM
SQL QUERY RESULTS TO TEXT FILE ram33654 Classic ASP Basics 0 August 16th, 2006 09:20 PM
Query returning 0 results although SQL is valid aquagal77 Classic ASP Databases 4 March 31st, 2005 11:06 AM
SQL count query not giving correct results hman SQL Language 2 March 16th, 2005 07:06 AM
SQL count query not giving correct results hman SQL Server 2000 1 March 15th, 2005 01:15 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.