经典SQL查询语句大全

2022-11-30 投稿:赵若喜 分享

select * from table1 where 工资>2500 and 工资<3000 //同上

select 姓名 from table1 where 性别='0' and 工资='4000'

select * from table1 where not 工资= 3200

select * from table1 order by 工资desc //将工资按照降序排列

select * from table1 order by 工资 asc //将工资按照升序排列

select * from table1 where year(出身日期)=1987 //查询table1 中所有出身在1987的人select * from table1 where name like '%张' /'%张%' /'张%' //查询1,首位字‘张’3,尾位字‘张’2,模糊查询

select * from table1 order by money desc //查询表1按照工资的降序排列表1 (升序为asc)

select * from table1 where brithday is null //查询表1 中出身日期为空的人

use 数据库(aa) //使用数据库aa

create bb(数据库) //创建数据库bb

create table table3 ( name varchar(10),sex varchar(2),money money, brithday datetime)//创建一个表3中有姓名,性别,工资,出身日期 (此表说明有四列)

insert into table3 values ('张三','男','2500','1989-1-5')//在表中添加一行张三的记录

alter table table3 add tilte varchar(10) //向表3 中添加一列“title(职位)”

alter table table3 drop column sex //删除table3中‘性别’这一列

drop database aa //删除数据库aa

drop table table3 //删除表3

delete * from table3 //删除table3 中所有的数据,但table3这个表还在

delete from table1 where 姓名='倪涛' and 日期 is null

delete from table1 where 姓名='倪涛' and 日期='1971'

select * into table2 from table3 //将表3中的所有数据转换成表2 (相当于复制)

update table3 set money=money*1.2 //为表3所有人工资都增长20%

update table3 set money=money*1.2 where title='经理' //为表3中“职位”是经理的人工资增长20%

update table1 set 工资= 5000 where 姓名='孙八' //将姓名为孙八的人的工资改为5000

update table1 set 姓名='敬光' where 姓名='倪涛' and 性别=1 //将性别为男和姓名为倪涛的人改为敬光

#经典SQL查询语句大全#相关文章

replace函数sql用法

在涉及到DataBase的开发的过程,经常遇到如下的场景:业务逻辑需要向数据库插入一条新数据,但是需要做如下的判断:1. 判断数据库里是否已经存在这样一条记录(有特定的判断依据);2.1 如果数据库里

0.2万人浏览 sqlreplaceSQL

sql语句进行排序

按修改的时间倒序排列语句为:select * from MyTable Order By ModifyTime Desc如果只想显示最新一条,语句为:select top 1 * from MyTab

0.2万人浏览 sqlsql语句SQL

更新表字段的sql语句

update主要用来更新表中的数据;语法为:update tableName set FiledName=NewValue[where condition]tableName为表名,FiledName

0.2万人浏览 sqlSQLSQL语句

sql语句大全及用法

SQL语言的核心语句是:SELECT语句,用于从表中选取数据SQL全称Structured Query Language(结构化查询语言),其核心是数据查询,其查询语言只有一条,即SELECT语句。本

0.2万人浏览 sqlSQLsql语句

sqlserver使用教程

1、首先我们打开SQL Server数据库,新建一个测试数据库,如下图所示。2、接下来需要下载SQL Server的JDBC驱动程序,如下图所示,驱动程序是一个Jar包文件。3、然后我们打开Eclip

0.2万人浏览 SQLServerserver

sql的九个常用语句

说在前面:SQL真的很简单很好学啊,完全不需要编程基础,1天之内立刻上手。首先花三分钟理清楚思路:1、SQL语句的基本结构就是:select a,b,c,d,efrom tableA解释为:从tabl

0.2万人浏览 sqlSQLSQL语句

sql语句大全实例教程

oracle分oracle实例和oracle数据库文件1、实例是指内存结构,包括SGA和Sga和后台进程,所有这些统一一个名字叫实例名。2、数据文件就是存数据的文件。关闭状态下,数据库文件存在磁盘上,

0.2万人浏览 SQLsql语句SQL语句