我有一个查询,它显示测试数据库中多个表的列。输出是来自世界各地的酒店及其相应的信息。我的搜索条件很简单;没有空白字段,我希望他们的电话号码不以 + 号开头。
它可以工作,但它会显示所有条目(就像它应该显示的那样)但是是否可以只显示找到的项目总数,例如,每个国家/地区?例如它在中国显示 5000 行,在意大利显示 3458 行,在加拿大显示 2050 行等。是否可以只显示找到的总数?5000:中国 3458:意大利 2050:加拿大等
我已经尝试过 COUNT 和 HAVING,但到目前为止它还没有为我工作。我还在这里查找了一些主题,但仍然没有成功。这是我的查询:
SELECT
hotel.id HotelID,
hotel.name Hotel_Name,
hotel.tel_area Area_Number,
hotel.tel Phone_Number,
city.name City,
region.name Region,
country.name Country,
country.id CountryID,
country.continent Continent,
hotel.web Website
FROM mydata.hotel as hotel
JOIN mydata.city as city ON hotel.city = city.id
JOIN mydata.region as region ON region.id = city.region
JOIN mydata.country as country ON country.id = region.country
where hotel.tel not like ''
and accos.tel not like '+%'
order by country.name
有人建议吗?