【发布时间】:2017-09-12 13:25:03
【问题描述】:
SELECT 'name' FROM 'players' WHERE 'id' IN
(SELECT 'player_id' from 'players_online' WHERE 'frags'=
(SELECT MAX(frags) FROM 'players_online'))
AND 'name' is not null LIMIT 1;
有两个表,在第二个表中有一个重要的最大值,称为 frags,我想从表 1 中提取一个名称,其中列 id 和 player_id 具有相同的值。当我在没有单引号的情况下检查它时,它可以工作,但我需要保留引号,因为 lua 脚本短语返回布尔表达式而不是字符串
Lua 代码:
BestPAl=db.storeQuery("SELECT name FROM players WHERE id IN(SELECT player_id from players_online WHERE frags=(SELECT MAX(frags) FROM players_online)) AND name is not null LIMIT 1;")
BestPA=result.getDataString(BestPAl)'code'
【问题讨论】:
-
¿消息错误?
-
#1064 - 你的语法有问题 obok ''players' WHERE 'id' IN(SELECT 'player_id' from 'players_online' WHERE 'frags'=(' 我需要保留这个单引号因为我想在lua脚本中提取一个字符串,当我离开引号时我得到一个布尔表达式而不是字符串
-
SQL 表单字符串文字中的单引号文本,而不是标识符。您的第一个查询尝试从字符串“players”中进行选择,这是无效的语法。您必须不使用引号或使用双引号。另外,请解释一下“短语”是什么意思(您的意思是“解析器”吗?)
-
你的意思是
BestPA=result.getDataString(BestPAl,"name")? -
我已经通过使用两个查询解决了这个问题 local BestPAl=db.storeQuery("SELECT
player_idFROMplayers_onlineORDER BYfragsDESC LIMIT 1") local BestPA=result .getDataInt(BestPAl, "player_id") result.free(BestPAl) 本地 BestPAm=db.storeQuery("SELECTnameFROMplayersWHEREid= " .. BestPA ) 本地 nejm=result.getDataString(BestPAm, "名称") result.free(BestPAm)