一.说明 几个简单的基本的sql语句,不常写,就容易忘记。
1.查询 select * from table1 where 范围
2.插入 insert into table1 (field1,field2)values(value1,value2)
3.删除 delete from table1 where 范围
4.更新 update table1 set field1=value1 ,field2= value2 where 范围
5.like查询 select * from table1 where filed1 like '%value1%'
6.排序 select * from table1 order by filed1 desc [or asc]
7.总数 select count(*) as totalcount from table1
8.求和 select sum(field1) as sumvalue from table1
9.平均 select avg(field1) as avgvalue from table1
10.最大 select max(field1) as maxvalue from table1
11.最小 select min(field1) as minvalue from table1
----between and ----
eg:
select *
from table1
where salary
between 2000 and 5000
select *
from table1
where salary >=2000 and salary <=5000
----or ----
eg:
select tname,dname,sal
from teacher
where dname='计算机'
or dname='生物'
order by dname
----not in ----
eg:
select tname,dname,sal,age
from teacher
where dname
not in('计算机','生物','机械工程')
order by dname
----not ----
eg:
select tname,dname,sal,age
from teacher
where
not dname = '计算机'
order by dname
select tname,dname,sal,age
from teacher
where
not sal > 1500
order by dname
-----------<> not != --------
not 可以有其他运算符组合查询
eg:
select tname,dname,sal,age
from teacher
where
not age between 40 and 50
order by dname
分享到:
相关推荐
几个T-Sql 的面试题几个T-Sql 的面试题几个T-Sql 的面试题几个T-Sql 的面试题几个T-Sql 的面试题几个T-Sql 的面试题几个T-Sql 的面试题几个T-Sql 的面试题几个T-Sql 的面试题几个T-Sql 的面试题几个T-Sql 的面试题几...
几个简单的基本的sql语句能教会你许多东西.
几个SQL 语句及其例子 几个SQL 语句及其例子
浅谈几个sql的日志概念浅谈几个sql的日志概念
SQL Server 设置数据区分大小写的五种方法: 第一种:在数据库中简单设置一下即可。 第二种: ALTER TABLE tb ALTER COLUMN colname nvarchar(100) COLLATE Chinese_PRC_CI_AS --不区分大小写 ALTER TABLE tb ALTER...
几个SQL面试题及答案.sql
SQL简单存储过程示例 内含存储过程简介及几个简单的例子。
sql一个字段中的某几个字updatesql一个字段中的某几个字update
VC的几个基于SQL操作实例。VC的几个基于SQL操作实例。
几个SQL_Server常用技巧,是SQL初学者的绝佳资料,看看有好处的
利用T-SQL语句实现的几个简单案例.pdf
P2_SQL的几个技术点
先看我之前写的几句简单的sql语句,自以为没有问题,但是编译直接报错。 String str = insert into XXX(a,b,c) values ('a.getA()','a.getB()','a.getC()');; 研究了半天发现应该是连接字符串问题,第...
SQL Server删除重复数据的几个方法SQL Server删除重复数据的几个方法
大文件不能打开,打开慢解决的工具,几个G的sql文件秒打开
Java防SQL注入,最简单的办法是杜绝SQL拼接,经验和技巧之谈,不错推荐。
sqldbx personal 3.5 已破解打开多个窗口的限制
几个很好的SQL题目,都是得好好想一想的,希望大家喜欢
一个对表进行操作的T-SQL语句通常都可产生或处理一组记录,但是许多应用程序,尤其是T-SQL嵌入的主语言,通常不能把整个结果集作为一个单元来处理,这些应用程序就需要用一种机制来保证每次处理结果集中的一行或几行...
sql优化的几种方法sql优化的几种方法sql优化的几种方法sql优化的几种方法sql优化的几种方法