musicbrainz无法按国家统计艺术家

时间:2017-11-20 13:53:53

标签: mysql sql musicbrainz

您好我正在使用musicbrainz数据库,我无法计算每个国家的所有艺术家,但无论我尝试哪个国家,我都会得到相同的错误,即使我尝试使用喜欢。任何人都可以告诉我我做错了什么?

  

错误:列“%u%”不存在第7行:WHERE 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
);

子查询工作正常,但主查询失败?任何想法为什么。

2 个答案:

答案 0 :(得分:1)

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;

答案 1 :(得分:1)

参见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;

双引号用于列名