日志文章

2007年06月04日 11:04:33

SQL表对比

select *
into db2
from zgk
where not exists
(select *
from mg1 where mg1.col007=zgk.col007 and mg1.col017=zgk.col017)




数据记录筛选
sql="select * from 数据表 where 字段名=字段值 order by 字段名 [desc]"

sql="select * from 数据表 where 字段名 like \'%字段值%\' order by 字段名 [desc]"

sql="select top 10 * from 数据表 where 字段名 order by 字段名 [desc]"

sql="select * from 数据表 where 字段名 in (\'值1\',\'值2\',\'值3\')"

sql="select * from 数据表 where 字段名 between 值1 and 值2"

AVG(字段名) 得出一个表格栏平均值
COUNT(*|字段名) 对数据行数的统计或对某一栏有值的数据行数统计
MAX(字段名) 取得一个表格栏最大的值
MIN(字段名) 取得一个表格栏最小的值
SUM(字段名) 把数据栏的值相加

SELECT *
FROM table_name1
WHERE column1 LIKE \'x%\'
说明:LIKE 必须和後面的\'x%\' 相呼应表示以 x为开头的字串。
SELECT *
FROM table_name1
WHERE column1 IN (\'xxx\',\'yyy\',..)
说明:IN 後面接的是一个集合,表示column1 存在集合里面。
SELECT *
FROM table_name1
WHERE column1 BETWEEN xx AND yy
说明:BETWEEN 表示 column1 的值介於 xx 和 yy 之间。

DELETE FROM table_name
WHERE conditions 说明:删除符合条件的资料。

Tags: SQL  

类别: 其他 |  评论(1) |  浏览(6038) |  收藏
发表评论