Re: Top 10 Query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I had an extra â=â sign by the WHERE, my mistake, I couldnât see it originally.  Ron

The Verse of the Day
âEncouragement from Godâs Wordâ
http://www.TheVerseOfTheDay.info 


From: Ron Piggott 
Sent: Saturday, January 08, 2011 7:42 AM
To: php-db@xxxxxxxxxxxxx 
Subject: Top 10 Query


I am trying to write a mySQL query to determine if the current word being displayed in the game is one of the top 10 most popular.  I am trying to achieve this by creating a table that tracks how many times each word was accessed.  A new row is created for each access to the word.  The table structure is as follows:

CREATE TABLE IF NOT EXISTS `bible_word_scramble_usage` (
  `reference` int(25) NOT NULL AUTO_INCREMENT,
  `bible_dictionary_reference` int(4) NOT NULL,
  `ip_address` varchar(20) NOT NULL,
  `date_accessed` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`reference`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=122 ;

The following is the SELECT query I need help tweaking.  What I am trying to do is select the top 10 most popular words and then use a second select to see if the word being displayed is one of the top 10 (IE using the search results of the 10 top SELECT query).

The error this query is currently giving me is: 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= `top_ten`.`bible_dictionary_reference` = 1 LIMIT 1'

This is the query:

SELECT `top_ten`.`bible_dictionary_reference` 
FROM ( 

SELECT `bible_dictionary_reference` , COUNT( `reference` ) AS word_usage
FROM `bible_word_scramble_usage` 
GROUP BY `bible_dictionary_reference` 
ORDER BY word_usage DESC 
LIMIT 10 
) AS top_ten
WHERE = `top_ten`.`bible_dictionary_reference` =1
LIMIT 1 

Thank you for helping me.  Ron

The Verse of the Day
âEncouragement from Godâs Wordâ
http://www.TheVerseOfTheDay.info 

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux