gpt4 book ai didi

Mysql显示记录甚至没有结果

转载 作者:行者123 更新时间:2023-11-29 06:58:32 26 4
gpt4 key购买 nike

我有两个表,即:列表和标签。这些是示例记录:

列表表
enter image description here
标签表
enter image description here
这是我的示例 SQL 查询:

SELECT l.tag,
count(case when l.type = 'Consumer' then l.type = '' end) as consumer,
count(case when l.type = 'Supplier' then l.type = '' end) as supplier
FROM listings AS l
LEFT JOIN tags AS t
ON l.tag = t.tag
GROUP BY t.tag, l.type

但是显示是这样的:
enter image description here


我想要这样的东西:
enter image description here

有什么想法可以做吗?我很乐意感谢任何形式的帮助。谢谢。

更新:更改为:

SELECT l.tag,
count(case when l.type = 'Consumer' then l.type = '' end) as consumer,
count(case when l.type = 'Supplier' then l.type = '' end) as supplier
FROM listings AS l
LEFT JOIN tags AS t
ON l.tag = t.tag
GROUP BY t.tag, l.type


这就是结果:
enter image description here

OUTER 关键字似乎有效,但我仍然需要为消费者和供应商显示带有 0 和 0 的 AZ。

最佳答案

试试这个..............

SELECT t.tag,
count(case when l.type = 'Consumer' then l.type = '' end) as consumer,
count(case when l.type = 'Supplier' then l.type = '' end) as supplier
FROM listings AS l
RIGHT JOIN tags AS t
ON l.tag = t.tag
GROUP BY t.tag

关于Mysql显示记录甚至没有结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44626355/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com