欢迎来到unity学习、unity培训、unity企业培训教育专区,这里有很多U3D资源、U3D培训视频、U3D教程、U3D常见问题、U3D项目源码,我们致力于打造业内unity3d培训、学习第一品牌。1、多表联结查询—分类。
1)内联结(inner join)
select u.name,s.grade from score as s inner join users as u on s.uid=u.id
2)外联结
——左外联结(left join)(跟表的位置有关)
select u.name,s.grade from score as s left join users as u on s.uid=u.id //会忽略score中grade为空的行。
select u.name,s.grade from users as u left join score as s on s.uid=u.id //会显示score中grade为空的行。
——右外联结(right join)(跟表的位置有关)
select u.name,s.grade from score as s right join users as u on s.uid=u.id //会显示score中grade为空的行。
select u.name,s.grade from users as u right join score as s on s.uid=u.id //会忽略score中grade为空的行。
2、模糊查询—like:查询时,字段中的内容并不一定与查询内容完全匹配,只要字段中含有这些内容。
select id,name from users where name like '%a%' 代表字段中带有a的。
3、模糊查询—between...and:把某一字段中内容在特定范围内的记录查询出来。
select id,name from users where id between 1 and 2
select id,name from users where id >=1 and id<=2
4、模糊查询—in:把某一字段中内容与所列出的查询内容列表匹配的记录查询出来。
select id,name from users where id in(1,2,3)
5、聚合函数。
1)sum:select sum(id) as 总和 from users //整个表中id的总和。
2)avg:select avg(id) as 平均 from users //整个表中的平均数。
3)max:select max(id) as 最大,min(id) as 最小 from users
4)count:
select count(*) as 总人数 from users
select count(password) as 总人数 from users
6、分组。
select id,avg(id) as 平均 from users group by id
select id,avg(id) as 平均 from users group by id,name
学习Unity3D之高级查询。
最新推荐文章于 2021-03-28 20:49:21 发布