我有点疑惑,有人可以查看这个查询并告诉我我做错了吗?
SELECT d.* FROM as_downloads d LEFT JOIN as_categories c ON (d.download_category_id = c.category_id) WHERE d.download_category_id != -1 LIMIT 30
从as_downloads
表中获取行但不加入类别表..
Theres没有错误,我曾在PHPMyAdmin中测试过相同的结果,这是使用的PHP代码
class Model_Downloads extends ModelType_PDO
{
public function fetchDownloads($limit)
{
$p = Registry::get('Config')->Database->prefix;
$query = "SELECT d.* FROM ".$p."downloads d LEFT JOIN ".$p."categories c ON d.download_category_id = c.category_id WHERE d.download_category_id != -1 LIMIT :limit";
$this->query = $this->prepare($query);
$this->query->bindValue(':limit',$limit,PDO::PARAM_INT);
if($this->query->execute())
{
return $this->query->fetchAll(PDO::FETCH_CLASS);
}
return false;
}
}
答案 0 :(得分:1)
您的查询仅选择下载表格中的列 - d.*
。您只需要从类别中指定所需的列。