enfekted
March 10th, 2005, 05:21 PM
Hello,
I'm having a problem converting a query set up for SQL server to MySQL. I'm not too familiar with the MySQL Syntax and am having a problem figuring out how to do subqueries.
Table "scores"
ID : Int(11)
Name : VarChar(45)
Difficulty : VarChar(15)
EntryDate : DateTime
Tics : BigInt(20)
View "Rankings"
CREATE VIEW Rankings AS
SELECT s.ID, s.Name, s.Tics, s.EntryDate, s.Difficulty,
(SELECT COUNT(*)+1
FROM scores sc
WHERE sc.Tics < s.Tics
AND sc.Difficulty = s.Difficulty) as Rank
FROM scores s
ORDER BY Difficulty, Rank ASC
Query that needs to be converted to MySQL
SELECT TOP 100 *
FROM Rankings
WHERE Difficulty = 'Easy'
Mostly, I'm having problem converting "Rankings" to MySQL because of the subquery.
Thanks for your help!
I'm having a problem converting a query set up for SQL server to MySQL. I'm not too familiar with the MySQL Syntax and am having a problem figuring out how to do subqueries.
Table "scores"
ID : Int(11)
Name : VarChar(45)
Difficulty : VarChar(15)
EntryDate : DateTime
Tics : BigInt(20)
View "Rankings"
CREATE VIEW Rankings AS
SELECT s.ID, s.Name, s.Tics, s.EntryDate, s.Difficulty,
(SELECT COUNT(*)+1
FROM scores sc
WHERE sc.Tics < s.Tics
AND sc.Difficulty = s.Difficulty) as Rank
FROM scores s
ORDER BY Difficulty, Rank ASC
Query that needs to be converted to MySQL
SELECT TOP 100 *
FROM Rankings
WHERE Difficulty = 'Easy'
Mostly, I'm having problem converting "Rankings" to MySQL because of the subquery.
Thanks for your help!