没有合适的资源?快使用搜索试试~ 我知道了~
数据库MySQL的常用查询语句和一些基本的查询语句,希望对你有帮助
资源推荐
资源详情
资源评论
语句全集
--列出pet所有的列
select * from pet
--列出指定的列
select name, owner form pet
--直接进行算术运算,对字段起别名
select sin(1+2) as sin
--where条件
select * from pet where (birth>'1980' and species='dog') or species='bird'
--对null的条件
select * from pet where sex is not null
--所有名字第四位是n的宠物信息是
select * from pet where owner like '___n%'
--所有主人名叫gwen或benny的宠物
select * from pet where owner in ('gwen' , 'benny')
--查询出生日期在90年代是宠物,相当与 >= and <=
select * from pet where birth between '1990' and '1999'
--按主人姓名排序,相同的按宠物姓名倒序排列
select * from pet order by owner, name desc
--查询性别为公的宠物,按生日倒序排列
select * from pet where sex='m' order by birth desc
--char_lenngth()返回的字符的长度,length()返回字节长度
SELECT owner,length(owner),char_length(owner) FROM pet p;
--列出养有宠物狗的人名
select distinct owner from pet where species='dog'
--用两种方法查询出所有狗和猫的名字、出生年份、出生月份
select name, left(birth,4) as year, mid(birth, 6, 2) as month from pet
--列出pet所有的列
select * from pet
--列出指定的列
select name, owner form pet
--直接进行算术运算,对字段起别名
select sin(1+2) as sin
--where条件
select * from pet where (birth>'1980' and species='dog') or species='bird'
--对null的条件
select * from pet where sex is not null
--所有名字第四位是n的宠物信息是
select * from pet where owner like '___n%'
--所有主人名叫gwen或benny的宠物
select * from pet where owner in ('gwen' , 'benny')
--查询出生日期在90年代是宠物,相当与 >= and <=
select * from pet where birth between '1990' and '1999'
--按主人姓名排序,相同的按宠物姓名倒序排列
select * from pet order by owner, name desc
--查询性别为公的宠物,按生日倒序排列
select * from pet where sex='m' order by birth desc
--char_lenngth()返回的字符的长度,length()返回字节长度
SELECT owner,length(owner),char_length(owner) FROM pet p;
--列出养有宠物狗的人名
select distinct owner from pet where species='dog'
--用两种方法查询出所有狗和猫的名字、出生年份、出生月份
select name, left(birth,4) as year, mid(birth, 6, 2) as month from pet
资源评论
wrfccl
- 粉丝: 8
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功