11.21 MySQL学习记录

2017-11-21 17:51:04


select *
from world.city;

select countrycode
from world.city;

/*distinct关键字作用于所有列,不仅仅跟着的后面那列*/
select distinct countrycode
from world.city;


/*检索前五行数据*/
select district
from world.city
limit 5;


/*从第十行开始,检索五行数据*/
select district
from world.city
limit 10,5;

/*按照字母顺序排列*/
select Name
from world.city
order by name;

/*先按GNP排列 再按Continent排列 (order by 2,3可以达到同样的效果,但更改时候容易出错)*/
select name, GNP, Continent
from world.country
order by GNP, Continent;

/*想在多个列上进行降序,需要在目标列后加desc*/
select name, region, population
from world.country
order by population desc;

/*order by语句需要放在where语句之后*/
select name, region, population
from world.country
where population >= 1000000
order by population;

select name, region, population
from world.country
where population between 5000000 and 10000000;

/*and关键字链接两个条件 or关键字满足其中一个条件就可以把数据返回*/
select name, district, population
from world.city
where CountryCode = 'PHL' and Population >= 400000

/*任何时候使用具有or和and操作符的where字句,都应该使用圆括号)*/
select name, district, population
from world.city
where (CountryCode = 'PHL' or CountryCode = 'BRA' )
and Population >= 400000

 

转载于:https://www.cnblogs.com/vincenthe1/p/7874532.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值