sql 语句 二
来源:互联网 发布:吉利知豆d2说明书 编辑:程序博客网 时间:2024/04/29 02:53
选单列数据
select name from totoro;
选两列数据
select id,name from totoro;
选单列中不重复的数据
select distinct name from totoro;
选出name列中名字是pangpang3的数据
select * from totoro where name='pangpang3';
选出age>3的数据
select * from totoro where age>3;
and
select * from totoro where id=1 and age=1;
or
select * from totoro where id=1 or age=3;
order by 排序
select age from totoro order by age;
选两列,按age排序
select id,age from totoro order by age;
DESC,降序
select age,name from totoro order by name DESC;
ASC,升序
select name,id from totoro order by name ASC;
部分插
insert into totoro (id,name) values (10,'feifei');
部分更新
update totoro set id=13,name='mark' where age=9;
删除
delete from totoro where id=1;
选前3行 limit
select * from totoro limit 3;
以i结尾的name
select * from totoro where name like '%i';
含om的name
select * from totoro where name like '%om%';
name第一个字符后是hu的
select * from totoro where name like '_hu';
name第2是a,第4是k
select * from totoro where name like '_a_k';
name是tom,ii
select * from totoro where name in ('tom','ii');
取anan和mary之间的name
select * from totoro where name between 'anan' and 'mary';
as指定别名
select name as n from totoro;
表名totoro as t
select t.id from totoro as t;
两张表中id相等的name
select totoro.id,totoro.name,user.name from totoro,user where totoro.id=user.id;
join on
select totoro.id,totoro.name,user.name from totoro join user on totoro.id=user.id order by totoro.id;
取两张表中id相同的数据
select totoro.id,totoro.name,user.name from totoro,user where totoro.id=user.id;
inner join
select totoro.id,totoro.name,user.id from totoro inner join user on totoro.id=user.id order by totoro.id;
select name from totoro;
选两列数据
select id,name from totoro;
选单列中不重复的数据
select distinct name from totoro;
选出name列中名字是pangpang3的数据
select * from totoro where name='pangpang3';
选出age>3的数据
select * from totoro where age>3;
and
select * from totoro where id=1 and age=1;
or
select * from totoro where id=1 or age=3;
order by 排序
select age from totoro order by age;
选两列,按age排序
select id,age from totoro order by age;
DESC,降序
select age,name from totoro order by name DESC;
ASC,升序
select name,id from totoro order by name ASC;
部分插
insert into totoro (id,name) values (10,'feifei');
部分更新
update totoro set id=13,name='mark' where age=9;
删除
delete from totoro where id=1;
选前3行 limit
select * from totoro limit 3;
以i结尾的name
select * from totoro where name like '%i';
含om的name
select * from totoro where name like '%om%';
name第一个字符后是hu的
select * from totoro where name like '_hu';
name第2是a,第4是k
select * from totoro where name like '_a_k';
name是tom,ii
select * from totoro where name in ('tom','ii');
取anan和mary之间的name
select * from totoro where name between 'anan' and 'mary';
as指定别名
select name as n from totoro;
表名totoro as t
select t.id from totoro as t;
两张表中id相等的name
select totoro.id,totoro.name,user.name from totoro,user where totoro.id=user.id;
join on
select totoro.id,totoro.name,user.name from totoro join user on totoro.id=user.id order by totoro.id;
取两张表中id相同的数据
select totoro.id,totoro.name,user.name from totoro,user where totoro.id=user.id;
inner join
select totoro.id,totoro.name,user.id from totoro inner join user on totoro.id=user.id order by totoro.id;
0 0
- 基本SQL语句(二)
- SQL 语句使用二
- SQL语句积累(二)
- sql语句(二)
- sql语句总结二
- SQL 语句学习(二)
- SQL 语句大全(二)
- SQL语句基础教程(二)
- SQL语句汇总(二)
- 二,SQL语句
- sql语句(二)
- 二、SQL语句优化
- sql 语句 二
- SQL经典语句二
- SQL语句汇总(二)
- sql语句二
- sql语句二
- 二.SQL语句优化
- C++求一个字符串中的所有回文字符串并且输出结果(字符串操作)
- 系统入门(11):Android4.0窗口机制和创建过程分析
- 服务器用U盘虚拟光驱装系统,有做RAID5,加载RAID驱动成功后,安装到最后会报“windows无法确定此计算机是否包含有效系统卷”错误
- 黑马程序员——Java基础——多线程(一)
- ubuntu php lamp环境搭建
- sql 语句 二
- Duplicate Emails
- ccna的Stp协议
- English Contest -- My English History
- storyboard 中coredata 出现问题:addPersistentStoreWithType 程序崩溃 后面还会跟着一串数据库地址,
- 【MAC使用技巧】黑苹果插入耳机之后依旧是外音
- 欧拉工程第25题:1000-digit Fibonacci number
- java.sql.SQLException: Access denied for user 'sa'@'localhost' (using password: NO)
- 进程与线程