2019-11-21sql疑惑

sql疑惑

1. between用法的疑惑

sqlzoo中
4. Which country has a population that is more than Canada but less than Poland? Show the name and the population.

刚开始想用between做代码如下

SELECT name,population FROM world WHERE population BETWEEN
((SELECT population FROM world where name='Poland') AND

(SELECT population FROM world where name='Canada'))

报错;错误为检查版本是否支持这种语法

后想使用>population>作为筛选条件

SELECT name,population FROM world WHERE
((SELECT population FROM world where name='Poland') >population>

(SELECT population FROM world where name='Canada'))

继续报错

不得不使用两个and进行连接

SELECT name,population FROM world WHERE
((SELECT population FROM world where name='Poland') >population AND population>

(SELECT population FROM world where name='Canada'))

2. 总结

  1. 多条件用and连接,即使是这种连续大于小于号的

3. 疑惑

between的错误依然没有找到

01-10 02:30