dpwdldgn43486 2014-08-05 10:53
浏览 65
已采纳

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

At the moment i have this query:

$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();

Where im trying to get games based on an input string but filtered by what platforms a user has, but it returns this error:

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

I have tried changing a few things around but nothing fixes this.

Also since I Havant been able to get there yet, would this work as a filter. The sub query will return multiple.

  • 写回答

2条回答 默认 最新

  • dsiy62758 2014-08-05 10:58
    关注

    You have a column value with backticks and its not valid it should be single quote or no quote if its INTEGER

    $qry = "SELECT platforms.PID
            FROM user_profile
            LEFT JOIN platforms
            ON platforms.reaccount = user_profile.subkey
            WHERE user_profile.UID = '".$data['id']."'";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱