下面是给定的表格。
----------------------------------
| area | country | date |
----------------------------------
| a1 | c1 | 13-01-2013 |
----------------------------------
| a2 | c2 | 06-01-2013 |
----------------------------------
| a3 | c1 | 12-01-2013 |
----------------------------------
| a4 | c2 | 10-01-2013 |
----------------------------------
| a5 | c3 | 13-01-2013 |
----------------------------------
| a1 | c1 | 13-01-2013 |
----------------------------------
| a2 | c2 | 06-01-2013 |
----------------------------------
| a3 | c1 | 12-01-2013 |
----------------------------------
| a4 | c2 | 10-01-2013 |
----------------------------------
| a5 | c3 | 13-01-2013 |
我希望我的查询能够跟随。
“显示在 2 个给定日期之间多次出现该地区的国家/地区的名称。”
我尝试了以下查询,但它给了我一个错误。> #1242 - 子查询返回多于 1 行
SELECT country
FROM table
WHERE area = (
SELECT area
FROM table
WHERE dateandtime > ' 13-01-2013'
AND dateandtime < '20-01-2013'
GROUP BY area
HAVING count(DISTINCT date) > 1 );