次の 2 つのテーブルを作成しました。
CREATE TABLE `Game` (
`GameName` varchar(30) NOT NULL,
`GameGenre` varchar(20) NOT NULL,
`GameDescription` varchar(500) NOT NULL,
`GameMode` varchar(20) NOT NULL,
PRIMARY KEY (`GameName`)
) ENGINE=InnoDB;
CREATE TABLE `GameScoreTotal` (
`ScoreID` int(3) NOT NULL AUTO_INCREMENT,
`GameName` varchar(30) NOT NULL,
`OverallScoreTotal` mediumint(9) NOT NULL,
`GraphicsTotal` mediumint(9) NOT NULL,
`StoryTotal` mediumint(9) NOT NULL,
`GameplayTotal` mediumint(9) NOT NULL,
`TimeTotal` mediumint(9) NOT NULL,
PRIMARY KEY (`ScoreID`),
CONSTRAINT FOREIGN KEY (`GameName`) REFERENCES `Game` (`GameName`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;
私のクエリは、に基づいて上位 10 試合のゲーム テーブルからすべての情報を返す必要がありますGameScoreTotal.OverallScoreTotal
。
私が試したクエリ:
SELECT GameName
FROM Game
FULL JOIN GameScoreTotal
ON Game.GameName=GameScoreTotal.GameName
ORDER BY OverallScoreTotal DESC
LIMIT 0, 10;
SELECT Game.GameName
FROM Game
FULL JOIN GameScoreTotal
ON Game.GameName=GameScoreTotal.GameName
ORDER BY OverallScoreTotal DESC
LIMIT 0, 10;
どちらのテーブルにも正当なレコードが含まれています。