我们今天学习了数据库语言,有左外连接,右外连接,内连接,还有具体的查询语句。
1.内连接:(两种方法)
select users.name, cart.amount, price from users as users
Inner join cart on users.id=cart.uid
Select u.name,c.amount,price from users as u
Inner join cart on u.id=c.uid
2.左外连接:
Select u.name,c.amount, c.price from users as u
Left join cart as c on u.id=c.uid
3.右外连接:
Select u.name,c.amount, c.price from users as u
Right join cart as c on u.id=c.uid
4.查询语句:
select name from users where name like ‘%99%’
Select name, age from users where age is null
Select name, age from users where age is not null
Select name,age from users where age between 21 and 29
Select name,age from users where age>=21 and age<=29
Select name,age from users where age not in(21,22,24)
Select sum(age) 总年龄 from users
Select avg(age) 平均年龄 from users
Select max(age) 最大值 from users
Select min(age) 最小值 from users
Select count(*) 总人数 from users
Select id 编号, avg(age) 平均年龄 from users group by id ,name
Select id,name , avg(age) 最大年龄 from users gruoup by id,name
声明:此篇文档时来自于【狗刨学习网】社区-unity极致学院,是网友自行发布的Unity3D学习文章,如果有什么内容侵犯了你的相关权益,请与官方沟通,我们会即时处理。
5.外键:
Alter table cart add constraint gf_users foreign key (uid) references users (id)
Alter table cart add constraint gh_users2 foreign key (uid)references users2 (name)
6.遍历器:
Foreach (Equip s in list)
{
console.Write (s.Id+” ”+s.Name+” ”+s.price+” ”+s.Amount+” ”+s.Remark);
}