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条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度