Notes
SQL运行顺序: from ---> where -----> select
distinct 选择不同选项, 多列选择时保留combination不同的项。
2. * 查出全部列
3. x + null = null
4. 查null : is null, is not null
between : between A and B, A和B都包括。
5.模糊查询:
like '%X%'
like '%X'
like 'X%'
like'__x' /*一个下滑线代表一个字*/
Basic:
1.SELECT population FROM world
WHERE name = 'Germany';
2.SELECT name, population FROM world
WHERE name IN ('Sweden', 'Norway', 'Denmark');
3.SELECT name, area FROM world
WHERE area BETWEEN 200000 AND 250000;
Select from World
1.
SELECT name, continent, population FROM world
2.
select name as country from world where population >= 200000000;
3.
select name as country, GDP/population from world where population >= 200000000;
4.
select name population/1000000 from world where continent='South America';
注意:select XXX as.... as 后设置的为一个短语(>=2个词) 需单引号。 如population in million
5. IN 的用法
6.
7. 基本OR
8. XOR,Exclusive OR:(A条件+ B条件取反) or (A取反+ B条件)
9. round (XXXX, 保留几位小数)
注意运算顺序:population/10^2-----实际运算=(popualtion/10)^2
10.
11.Length: returns the number of characters in string s.
12. 选择AB不等的项。 A!= B; <>