Musicbrainz无法按国家统计艺术家


嗨,我

正在使用musicbrainz数据库,我在计算每个国家的所有艺术家时遇到问题,但是无论我尝试哪个国家/地区,即使我尝试使用like,我也会遇到相同的错误。请谁能告诉我我做错了什么?

错误:列"%u%"不存在 第 7 行:其中 AREA.NAME 类似于"%u%">

SELECT COUNT(artist.name)
FROM artist
JOIN area ON artist.area = area.id 
JOIN label ON area.id = label.area
JOIN country_area ON area.id = country_area.area
JOIN release_country ON country_area.area = release_country.country
WHERE AREA.NAME LIKE "%dom"
GROUP BY release_country.country
limit 5;

更新:

musicbrainz_db=> SELECT COUNT(artist.name)
musicbrainz_db-> FROM artist
musicbrainz_db-> JOIN area ON artist.area = area.id
musicbrainz_db-> JOIN label ON area.id = label.area
musicbrainz_db-> JOIN country_area ON area.id = country_area.area
musicbrainz_db-> JOIN release_country ON country_area.area = 
release_country.country
musicbrainz_db-> WHERE AREA.NAME LIKE '%dom'
musicbrainz_db-> GROUP BY release_country.country
musicbrainz_db-> limit 5;

错误:由于语句超时而取消语句

我的老师刚刚过来,说没有子查询就行不通?

select area.name, label_count
from area
where label_count in 
(
    select area.name, count(label.id) as "label_count"
    from area
    JOIN label on area.id = label.area
    group by area.name
);

子查询工作正常,但主查询失败?知道为什么。

SELECT COUNT(artist.name)
FROM artist
JOIN area ON artist.area = area.id 
JOIN label ON area.id = label.area
JOIN country_area ON area.id = country_area.area
JOIN release_country ON country_area.area = release_country.country
WHERE AREA.NAME LIKE '%u%'
GROUP BY release_country.country
limit 5;

参见 MySQL 官方文档

https://dev.mysql.com/doc/refman/5.7/en/string-comparison-functions.html

并尝试使用单引号

SELECT COUNT(artist.name)
FROM artist
JOIN area ON artist.area = area.id 
JOIN label ON area.id = label.area
JOIN country_area ON area.id = country_area.area
JOIN release_country ON country_area.area = release_country.country
WHERE AREA.NAME LIKE '%dom'
GROUP BY release_country.country
limit 5;

双引号用于列名

相关内容

  • 没有找到相关文章

最新更新