未知列和过滤器通过多个返回子查询


Unknown column and filter by multiple return subquery

现在我有这个查询:

$qry = "SELECT platforms.PID
        FROM user_profile
        LEFT JOIN platforms
        ON platforms.relaccount = user_profile.subkey
        WHERE user_profile.UID = `".$data['id']."`";
$games = $this->db->select('main.APPID, games_other.name, games_other.logo')
                 ->select('platforms.PID, platforms.name AS pname, platforms.logo AS plogo')
                 ->select('('.$qry.') AS filt', null, FALSE)
                 ->from('games_link AS main')
                 ->join('games_platforms', 'games_platforms.APPID = main.APPID', 'left')
                 ->join('platforms', 'platforms.PID = games_platforms.PID', 'left')
                 ->join('games_other', 'games_other.APPID = main.GB_ID', 'left')
                 ->like('games_other.name', $name)
                 ->where('platforms.PID', 'filt')
                 ->limit(15)
                 ->get();

我试图根据输入字符串获得游戏,但根据用户拥有的平台进行过滤,但它返回此错误:

Unknown column 'Cf9nHvOlaaLzFRegX2Il' in 'where clause'
SELECT `main`.`APPID`, `games_other`.`name`, `games_other`.`logo`, `platforms`.`PID`, `platforms`.`name` AS pname, `platforms`.`logo` AS plogo, (SELECT platforms.PID FROM user_profile LEFT JOIN platforms ON platforms.reaccount = user_profile.subkey WHERE user_profile.UID = `Cf9nHvOlaaLzFRegX2Il`) AS filt FROM (`games_link` AS main) LEFT JOIN `games_platforms` ON `games_platforms`.`APPID` = `main`.`APPID` LEFT JOIN `platforms` ON `platforms`.`PID` = `games_platforms`.`PID` LEFT JOIN `games_other` ON `games_other`.`APPID` = `main`.`GB_ID` WHERE `platforms`.`PID` = 'filt' AND `games_other`.`name` LIKE '%a%' LIMIT 15
Filename: response/update.php

我试过改变一些东西,但没有解决这个问题。

也因为我还没有能够到达那里,这将作为一个过滤器工作。子查询将返回多个

你有一个带反引号的列值,它是无效的如果是INTEGER,它应该是单引号或者不引号

$qry = "SELECT platforms.PID
        FROM user_profile
        LEFT JOIN platforms
        ON platforms.reaccount = user_profile.subkey
        WHERE user_profile.UID = '".$data['id']."'";

你的问题在这里:

WHERE user_profile.UID = `Cf9nHvOlaaLzFRegX2Il`

反引号,',转义数据库对象(视图名,表名,列名…)等等)。

字符串值应该用单引号'.

转义。

我要小心连接的值,你可能应该绑定它们,如果可能的话。