带有限制错误的mySQL子查询

时间:2016-12-12 12:02:27

标签: mysql subquery limit

我有两个游戏部分,我有一个问题。什么时候第一节比赛我不想再在第二部分给她看。 对于第一节中的节目游戏我使用:

SELECT *,platform.platformName FROM games 
JOIN platform ON(platform.PlatformID=games.GamePlatform) 
WHERE GameDate <= NOW() AND GameSlide = 0 
GROUP BY GameName 
HAVING 1 
ORDER BY `games`.`GameDate` DESC LIMIT 8

对于第二部分的节目游戏:

SELECT *,platform.platformName 
FROM games 
JOIN platform ON(platform.PlatformID=games.GamePlatform) 
WHERE platform.PlatformID = 2 AND GameSlide = 0 
GROUP BY GameName 
HAVING 1 
order by rand(dayofyear(CURRENT_DATE)) 
LIMIT 8

我试着像这样制作子查询:

SELECT *,platform.platformName 
FROM games 
JOIN platform ON(platform.PlatformID=games.GamePlatform) 
WHERE games.GameID 
NOT IN(
       SELECT GameID 
       FROM games 
       WHERE GameDate <= NOW() AND GameSlide = 0 
       GROUP BY GameName 
       HAVING 1 
       ORDER BY `games`.`GameDate` DESC LIMIT 8
      ) AND platform.PlatformID = 2 AND GameSlide = 0 
GROUP BY GameName 
HAVING 1 
order by rand(dayofyear(CURRENT_DATE)) LIMIT 8

但MySQL调用错误:#1235 - This version of MariaDB doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'

你能帮帮我吗? 对不起我的英语。我尽我所能。

1 个答案:

答案 0 :(得分:0)

我已经完成了。我使用select创建了一个新视图。

SELECT *,platform.platformName FROM games JOIN platform ON(platform.PlatformID=games.GamePlatform) WHERE GameID NOT IN (SELECT * FROM novinky) AND platform.PlatformID = 2 AND GameSlide = 0 GROUP BY GameName HAVING 1 order by rand(dayofyear(CURRENT_DATE)) LIMIT 8

然后在View中使用NOT IN和SELECT:

var data = google.visualization.arrayToDataTable([
 ['Label', 'Value'],
 ['', {v: <Your_own_value_of_the_gauge_meter>, f: ''}],
]);