Linux - C数据库编程(预习内容四)
来源:互联网 发布:最好的seo课程 编辑:程序博客网 时间:2024/05/10 00:35
单表查询:
查询是对数据库的最常用操作。查询的结果可以理解为得到了一个新表,只是这个表并没有保存在数据库里,而是以某种方式显示给查询者。
用select语句可以对数据库进行查询
select ID, Name from student where Sex = 'F';
查询结果中出现表的所有字段(*)
select * from score where score < 60;
查询结果中没有重复的记录(distinct)
select distinct * from score;
查询结果按某个字段的值进行排序(order by)
select * from score order by score asc;
select * from score order by score desc;
多表联合查询:
查询数据库时,也可以将多个表的内容放在一起进行查询
select student.name from student, score where student.id = score.id and score.score < 60;
上述语句中,from关键字后出现了两个表名student和score,表示对这两个表进行联合查询。
使用别名进行多表联合查询:
可以使用表的别名以避免多次输入较长的表名,使代码更清晰
select A.name from student A, score B where A.id = B.id and B.score < 60;
上述语句中,from关键字后的表名都指定了一个别名。
注意:别名只在当前语句中有效。
0 0
- Linux - C数据库编程(预习内容四)
- Linux - C数据库编程(预习内容一)
- Linux - C数据库编程(预习内容二)
- Linux - C数据库编程(预习内容三)
- Linux - C数据库编程(预习内容五)
- Linux - C数据库编程(预习内容六)
- Linux - C预习内容(四)
- Linux - C进程间通信(预习内容四)
- Linux-C预习内容(一)
- Linux-C预习内容(二)
- Linux-C预习内容(三)
- Linux - C预习内容(五)
- Linux - C预习内容(六)
- Linux - C预习内容(七)
- Linux - C预习内容(八)
- linux预习(四)
- Linux - C通信间进程(预习内容二)
- Linux - C进程间通信(预习内容三)
- C++ hdu 2055 An easy problem
- JSON学习入门
- 【C++研发面试笔记】3. 命名空间与内存管理
- 进入OS前的两步之PendSV(任务切换)
- OpenCL笔记
- Linux - C数据库编程(预习内容四)
- 嵌入式系统学习(九)-用过内核驱动操作GPIO
- Struts2 formBean传值
- map应用:反片语
- STL(七):stack 与 queue
- 嵌入式Linux移植之initramfs
- linux如何用fdisk命令分区
- 拓扑排序 - Topological Sort
- tomcat热部署实现方法1