11.23 MySQL学习记录

/*用or 一样可以到达此效果,但用in操作符更好*/
select governmentform, name, gnp
from world.country
where Continent in ('aisa', 'europe');

/*通配符*/
/* %百分号表示任何字符出现任何次数,_下划线用途相同但只是匹配单个字符*/
/*在continent中,找出以America结尾的所有结果*/
select name, region, population, Continent
from world.country
where Continent like '% america';

select *
from world.country

/*concat字段用于拼接字段,方式如下*/
select concat(name, '(' , countrycode, ')')
from world.city
order by name;

/*as用于拼接字段的命名*/
select concat(name, '(' , countrycode, ')')
as namecode
from world.city
order by name;

/*执行算数计算*/
select name, population, population/SurfaceArea as average_area
from world.country
where Continent in ('Asia');

posted on 2017-11-23 20:44  vincenthe1  阅读(74)  评论(0)    收藏  举报

导航