我有一个漫画数据库,其中包含漫画,信用和贡献者详细信息表。我正在尝试使用此SQL查询过滤表:
select参数带有*以显示所有内容,但此处似乎没有显示
SELECT
cc.*,
ct.*,
cpub.*,
c.*,
cs.*
FROM
comic_types AS ct,
comics_publisher AS cpub,
comics AS c,
comics_series AS cs,
comic_credits AS cc
WHERE
c.comic_indexkey = cc.comic_index_key
AND cpub.publisher_index_key = c.comic_publisher
AND c.comic_series = cs.comics_seriesindexkey
AND ct.comic_typeindexkey = c.comic_type
AND cpub.publisher_index_key = c.comic_publisher
ORDER BY
comic_title ASC,
comic_series ASC
LIMIT 0, 15
将极限值放在此处进行分页。
有些漫画的贡献者相同,但角色不同(例如漫画A的作者B和插图画家B)。这意味着我有两个结果相同。我使用了一个数组,并继续声明,使重复记录不显示。
$comics_in_table = array();
if (in_array($comic['comic_indexkey'], $comics_in_table)) {
continue;
}
由此造成的问题是,分页仅显示每页5个而不是15个,大概是因为它检测到10个结果被“隐藏”了
到目前为止,我们一直按照这种帮助进行创建:
SELECT
cc.*,
ct.*,
cpub.*,
c.*,
cs.*
FROM
comic_types AS ct,
comics_publisher AS cpub,
comics AS c,
comics_series AS cs,
comic_credits AS cc
WHERE
c.comic_indexkey = cc.comic_index_key
AND cpub.publisher_index_key = c.comic_publisher
AND c.comic_series = cs.comics_seriesindexkey
AND ct.comic_typeindexkey = c.comic_type
AND cpub.publisher_index_key = c.comic_publisher
GROUP BY
cc.comic_index_key
ORDER BY
c.comic_title ASC,
c.comic_series ASC
LIMIT 0, 15
SQL返回此问题:
#1055-SELECT列表的表达式#1不在GROUP BY子句中,并且包含未聚合的列'sewters.cc.credit_index_key',该列在功能上不依赖于GROUP BY子句中的列;这与sql_mode = only_full_group_by
不兼容
答案 0 :(得分:0)
尝试使用
SELECT DISTINCT cc.*, ct.* ...
或附加
GROUP BY fieldname
在SELECT查询的末尾,其中fieldname
是您要分组为一个条目的数据库列。