unity学习之高级查询

本文详细介绍了在Unity3D中进行高级查询的方法,包括模糊查询(Like、Is null、Between...And、In),聚合函数(Sum、Avg、Max、Min、Count),分组查询(Group by、Having),以及多表联合查询(内连接、左外连接、右外连接)。通过这些技巧,开发者可以更高效地检索和操作游戏数据。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

unity学习,希望我的博客能给朋友们带来帮助


模糊查询:


    Like

    查询时,字段中的内容并不一定与查询内容完全匹配,只要字段中含有这些内容

       select id,name from users where name like 'a%'

       select id,name from users where name like '%a%'--这种形式指只要有a就可以了,不在意a所在的位置

 

    Is null

    把某一字段中内容为空的记录查询出来

 

    Between。。。And

    把某一字段中内容在特定范围内的记录查询出来

       select id,name from users where id between 1 and 2

       select id,name from users where id >=1 and id<=2   ---两种方法都可以

 

    In

    把某一字段中内容与所列出的查询内容列表匹配的记录查询出来

         select id,name from users where id in(1,2,3)

 

聚合函数


    sum  

       select sum(id) as 总和 from users

 

    avg

       select avg(id) as 平均 from users

 

    Max   min

       select max(id) as 最大,min(id) as 最小 from users

 

    count

       select count(*) as 总人数 from users

       select count(password) as 总人数 from users

 

分组查询


    group by

        select id,avg(id) as 平均 from users group by id  --单行

        select id,avg(id) as 平均 from users group by id,name  --多行

 

    Having

        Select StudentID as 学员编号,CourseID as 内部测试, AVG(Score) as 内部测试平均成绩

        from Score group by StudentID,CourseID having count(Score)>1

 

    分组查询对比

        1where子句从数据源中去掉不符合其搜索条件的数据

        2group by子句搜集数据行到各个组中,统计函数为各个组计算统计值

        3having子句去掉不符合其组搜索条件的各组数据行

 

多表联合查询

 

    内连接查询(跟表的位置无关)

         select u.name,s.grade from score as s inner join users as u on s.uid=u.id

         select u.name,s.grade from users as u  inner join score as s on s.uid=u.id

 

    左外连接查询(跟表的位置有关)

         select u.name,s.grade from score as s left join users as u on s.uid=u.id

         select u.name,s.grade from users as u  left join score as s on s.uid=u.id

 

    右外连接查询(跟表的位置有关)

         select u.name,s.grade from score as s right join users as u on s.uid=u.id

         select u.name,s.grade from users as u  right join score as s on s.uid=u.id

 

 更多精彩请点击 http://www.gopedu.com/article

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值