2019-11-21sql疑惑

时间:2019-11-21
本文章向大家介绍2019-11-21sql疑惑,主要包括2019-11-21sql疑惑使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

2019-11-21sql疑惑

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的错误依然没有找到

原文地址:https://www.cnblogs.com/yuvejxke/p/11906195.html