Sql常用语句

1.插入表数据:

insert into 表名1 (字段1,字段2) values(字段1值,字段2值);

2.删除表数据:

delete:delete from 表名1 where 范围(删除表内符合条件的内容) delete from 表名1(清空数据表内容,不释放空间,即:下次插入表数据,id依然接着删除数据的id继续增加) truncate:truncate table 表名1(清空表数据,释放空间,即:下次插入表数据,id从1重新开始) drop:drop table 表名1(整张表被删除,要使用该表必须重新建)

3.修改表数据:

update 表名1 set 字段名 = ‘新值’ where 范围

4.查询表数据:

查询数据:select * from table1 where 范围 总数:select count (*) from table1 where 范围 select count (distinct(字段1) from table1 where 范围(distinct可去重) 求和:select sum (字段1) from table1 where 范围 平均:select avg (字段1) from table1 where 范围 最大:select max (字段1) from table1 where 范围 最小:select min (字段1) from table1 where 范围 排序:select * from table1 where 范围 order by 排序字段名 desc(desc逆序排序。默认是正序排序asc)

5.复杂查询:

嵌套查询:多个查询语句嵌套在一起查询,一般嵌套的查询语句放在where 或 having 的后面 例: select * from table1 where status in(select status from table2)

最近的文章

软件测试流程

一、测试计划测试计划(Testing plan),描述了要进行的测试活动的范围、方法、资源和进度的文档;是对整个信息系统应用软件组装测试和确认测试。 它确定测试项、被测特性、测试任务、谁执行任务、各种可能的风险。测试计划可以有效预防计划的风险,保障计划的顺利实施。测试计划编写6要素?(5W1H)1) why——为什么要进行这些测试;2) what—测试哪些方面,不同阶段的工作内容;3) when—测试不同阶段的起止时间;4) where—相应文档,缺陷的存放位置,测试环境等;5) wh...…

继续阅读
更早的文章

Linux常用命令

关机 (系统的关机、重启以及登出 )shutdown -h now 关闭系统(1) init 0 关闭系统(2) telinit 0 关闭系统(3) shutdown -h hours:minutes & 按预定时间关闭系统 shutdown -c 取消按预定时间关闭系统 shutdown -r now 重启(1) reboot 重启(2) logout 注销文件和目录cd /home 进入 ‘/ home’ 目录’ cd .. 返回上一级目录 cd ../.. 返回上两级目录 c...…

继续阅读