简单查询

–【指定数据库】
use demo
go

–【1】查询表的所有数据
–【语法】select * from 表名
select * from hanshu

–【2】查询表中的列
–【语法】select 列名1,列名2,列名3… from 表名
select name from hanshu

–【3】查询表中列名为女的数据,或者是id=1,或者是add=‘湖南益阳’
–【语法】select * from 表名 where sex=‘女’
select * from hanshu where sex=‘女’

–【4】查询表中name字段包含汤的数据
–【语法】select * from 表名 where 列名 like ‘汤%’
select * from hanshu where name like ‘汤%’

–【5】查询表字段moeny中5到12之间的数据
–【语法】select * from 表名 where 列名 between 数字 and 数字
select * from hanshu where moeny between 5 and 12

–【6】查询表字段moeny中2.5.20数据
–【语法】select * from 表名 where 列名 in(2,5,20)
select * from hanshu where moeny in(2,5,20)

–【7】求表中moeny的平均值
–【语法】select avg(列名) from 表名
select avg(moeny) from hanshu ;

–【8】求表中moeny的总和
–【语法】select sum(列名) from 表名
select sum(moeny) from hanshu ;

–【9】求表中字段moeny小于20的数据
–【语法】select * from 表名 where 字段名<20
select * from hanshu where moeny<20

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值