我正在使用支持MySQL和SQLite的前端。
但是,我运行的其中一个查询在UPDATE部分中有JOIN。通过谷歌搜索,SQLite不支持。
查询是这样的:
UPDATE playertimes t
LEFT JOIN
(SELECT MIN(time) mintime,
MAP,
track,
style
FROM playertimes
GROUP BY MAP,
track,
style) minjoin ON t.time = minjoin.mintime
AND t.MAP = minjoin.MAP
AND t.track = minjoin.track
AND t.style = minjoin.style
JOIN
(SELECT ((50.0 * 2) * 1.5) points) best
JOIN
(SELECT (COUNT(*) * (2 / 10.0)) points,
MAP,
track,
style
FROM playertimes
GROUP BY MAP,
track,
style) additive ON t.MAP = additive.MAP
AND t.track = additive.track
AND t.style = additive.style
JOIN
(SELECT MIN(time) lowest, (MIN(time) / 15.0) points,
MAP,
track,
style
FROM playertimes
GROUP BY MAP,
track,
style) FINAL ON t.MAP = FINAL.MAP
AND t.track = FINAL.track
AND t.style = FINAL.style
JOIN
(SELECT (1.0) style, (1.0) track) multipliers
SET t.points = (CASE
WHEN minjoin.mintime IS NOT NULL THEN (((best.points + additive.points + FINAL.points) * multipliers.style) * multipliers.track)
ELSE (((((best.points + additive.points + FINAL.points) * multipliers.style) * multipliers.track) * (FINAL.lowest / t.time)) * 0.85)
END)
WHERE t.MAP = 'bhop_atom'
AND t.track = 0
AND t.style = 0;
错误:
near "t": syntax error
(我知道像multipliers
选择这样的部分看起来在SQL级别没有任何意义,但我计划很快将其更改为动态。其中一些部分实际上被变量替换在我的前端。)
我的目标是只在一个初始查询中完成此查询的最终结果(子查询很好)。我怎样才能实现它?如果最终查询与MySQL不兼容,那就没问题,因为我让应用程序发送不同的MySQL或SQLite查询,以防它们不兼容。
注意:结果与我希望它们在MySQL上运行此查询时完全一样。