Top 10 Query
am 08.01.2011 13:42:10 von ron.piggott
------=_NextPart_000_0004_01CBAF07.8ED4BE50
Content-Type: text/plain;
charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
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=3DMyISAM DEFAULT CHARSET=3Dlatin1 AUTO_INCREMENT=3D122 ;
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:=20
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 '=3D =
`top_ten`.`bible_dictionary_reference` =3D 1 LIMIT 1'
This is the query:
SELECT `top_ten`.`bible_dictionary_reference`=20
FROM (=20
SELECT `bible_dictionary_reference` , COUNT( `reference` ) AS word_usage
FROM `bible_word_scramble_usage`=20
GROUP BY `bible_dictionary_reference`=20
ORDER BY word_usage DESC=20
LIMIT 10=20
) AS top_ten
WHERE =3D `top_ten`.`bible_dictionary_reference` =3D1
LIMIT 1=20
Thank you for helping me. Ron
The Verse of the Day
â=9CEncouragement from Godâ=99s Wordâ=9D
http://www.TheVerseOfTheDay.info=20
------=_NextPart_000_0004_01CBAF07.8ED4BE50--
Re: Top 10 Query
am 08.01.2011 14:31:41 von ron.piggott
------=_NextPart_000_0016_01CBAF0E.799E94F0
Content-Type: text/plain;
charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
I had an extra â=â=9D sign by the WHERE, my mistake, I =
couldnâ=99t see it originally. Ron
The Verse of the Day
â=9CEncouragement from Godâ=99s Wordâ=9D
http://www.TheVerseOfTheDay.info=20
From: Ron Piggott=20
Sent: Saturday, January 08, 2011 7:42 AM
To: php-db@lists.php.net=20
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=3DMyISAM DEFAULT CHARSET=3Dlatin1 AUTO_INCREMENT=3D122 ;
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:=20
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 '=3D =
`top_ten`.`bible_dictionary_reference` =3D 1 LIMIT 1'
This is the query:
SELECT `top_ten`.`bible_dictionary_reference`=20
FROM (=20
SELECT `bible_dictionary_reference` , COUNT( `reference` ) AS word_usage
FROM `bible_word_scramble_usage`=20
GROUP BY `bible_dictionary_reference`=20
ORDER BY word_usage DESC=20
LIMIT 10=20
) AS top_ten
WHERE =3D `top_ten`.`bible_dictionary_reference` =3D1
LIMIT 1=20
Thank you for helping me. Ron
The Verse of the Day
â=9CEncouragement from Godâ=99s Wordâ=9D
http://www.TheVerseOfTheDay.info=20
------=_NextPart_000_0016_01CBAF0E.799E94F0--