SQL分页查询
thunder:
1.MYSQL实现
mysql> select * from user;
+----+----------+----------+-----------------+
| ID | username | password | email |
+----+----------+----------+-----------------+
| 1 | admin | admin | abc@yahoo.cn |
| 2 | thomas | 159753 | thomas@yahoo.cn |
| 3 | thomas1 | 159753 | thomas@yahoo.cn |
| 4 | huhu | 159753 | hu@yahoo.cn |
| 5 | fdg | dfg | fdg |
| 6 | sdf | sd | sdf@yahoo.cn |
| 7 | d | d | d@d.cn |
+----+----------+----------+-----------------+
7 rows in set (0.00 sec)
mysql> select * from user limit 3,2;
+----+----------+----------+-------------+
| ID | username | password | email |
+----+----------+----------+-------------+
| 4 | huhu | 159753 | hu@yahoo.cn |
| 5 | fdg | dfg | fdg |
+----+----------+----------+-------------+
2 rows in set (0.00 sec)
mysql>
===================================================
2.MSSQLServer实现
select top 5 function_id,function_name from d_function
where function_id not in (select top 5 function_id from d_function)
6 月统计
7 部门查询
8 公司查询
9 工程招标
10 工程总结
相关文档:
方法一、尽量使用复杂的SQL来代替简单的一堆 SQL.
同样的事务,一个复杂的SQL完成的效率高于一堆简单SQL完成的效率。有多个查询时,要善于使用JOIN。
oRs=oConn.Execute("SELECT * from Books")
while not oRs.Eof
strSQL = "SELECT * from Authors WHERE AuthorID="&oRs("AuthorID") oRs2=oConn.Execute(strSQ ......
正确的修改方法:sql批量修改字段内容的语句
1、没试过,网上搜索的
引用
update '表名' set 要修改字段名 = replace (要修改字段名,'被替换的特定字符','替换成的字符')
2、自己按照一个一个修改是看数据表总结的
例如偶修改自己博客boblog_replies表中的adminrepid和adminreplier字段值:
UPDATE `xxx`.`boblog_ ......
低效: (索引失效)
SELECT … from DEPARTMENT WHERE DEPT_CODE IS NOT NULL;
高效: (索引有效)
SELECT … from DEPARTMENT WHERE DEPT_CODE >=0;
(27)总是使用索引的第一个列:
如果索引是建立在多 ......
在T-SQL中监视进程
DBA更愿意使用T-SQL的原因是可以比“活动监视器”更加灵活地获得信息。
1. sp_who和sp_who2
存储过程sp_who也返回当前连接数据库实例,与“活动监视器”非常类似。然而,用户可能发现自己更愿意使用未公开说明的sp_who2存储过程,因为它提供 ......