多个内部连接中的计数列
Count Column in multiple inner join
我想获得 groupby 的计数(bebleiotheque.type),它的工作但是当我添加多个 many2many 字段以获得多本书或每个 bebeliotheque 行的多个雇主时,我的计数上升
如何获取 groupby 的真实计数(bebeliotheque 类型)
看看我的应用程序列表 bebeliotheque,我重新组合了所有相同的 bebeliotheque 名称,但我有一个不正确的(计数)
预览
图片 > http://rezigdev.com/image_202112522328.jpg
视频 > https://rezigdev.com/preview.mp4
sql查询
SELECT
bibliotheque.name, GROUP_CONCAT(book.name) as books, GROUP_CONCAT(employers.name) as employers, COUNT(bibliotheque.name)
FROM
bibliotheque
left join
x_x_bibliotheque_book
ON x_x_bibliotheque_book.bibliotheque_id = bibliotheque.id
left join
book
ON x_x_bibliotheque_book.book_id = book.id
left join
x_x_bibliotheque_employers
ON x_x_bibliotheque_employers.bibliotheque_id = bibliotheque.id
left join
employers
ON x_x_bibliotheque_employers.employer_id = employers.id
Group BY
bibliotheque.name
解决方案:
计数(不同 bibliotheque.id)
我想获得 groupby 的计数(bebleiotheque.type),它的工作但是当我添加多个 many2many 字段以获得多本书或每个 bebeliotheque 行的多个雇主时,我的计数上升
如何获取 groupby 的真实计数(bebeliotheque 类型)
看看我的应用程序列表 bebeliotheque,我重新组合了所有相同的 bebeliotheque 名称,但我有一个不正确的(计数)
预览
图片 > http://rezigdev.com/image_202112522328.jpg
视频 > https://rezigdev.com/preview.mp4
sql查询
SELECT
bibliotheque.name, GROUP_CONCAT(book.name) as books, GROUP_CONCAT(employers.name) as employers, COUNT(bibliotheque.name)
FROM
bibliotheque
left join
x_x_bibliotheque_book
ON x_x_bibliotheque_book.bibliotheque_id = bibliotheque.id
left join
book
ON x_x_bibliotheque_book.book_id = book.id
left join
x_x_bibliotheque_employers
ON x_x_bibliotheque_employers.bibliotheque_id = bibliotheque.id
left join
employers
ON x_x_bibliotheque_employers.employer_id = employers.id
Group BY
bibliotheque.name
解决方案: 计数(不同 bibliotheque.id)