惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
量子位
腾讯CDC
A
About on SuperTechFans
小众软件
小众软件
Microsoft Azure Blog
Microsoft Azure Blog
T
Tailwind CSS Blog
V
V2EX
B
Blog RSS Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
GbyAI
GbyAI
Recent Announcements
Recent Announcements
Microsoft Security Blog
Microsoft Security Blog
博客园 - 叶小钗
罗磊的独立博客
宝玉的分享
宝玉的分享
WordPress大学
WordPress大学
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家
V
Visual Studio Blog
D
DataBreaches.Net
博客园 - 三生石上(FineUI控件)
月光博客
月光博客
有赞技术团队
有赞技术团队

博客园 - 牵牛望岳

ICloneable 接口--c# 深复制与浅复制 IDisposable接口详解 C# 中用 PadLeft、PadRight 补足位数 listbox控件的一些操作 IsPostBack用法,Page.IsValid的用法 IIf函数 替换、恢复Html中的特殊字符 C#连接数据库的一些鲜为人知的方法 C#关键字 【推荐】常用 SQL 语句大全 CSS中的黄金分割率 解析.net中ref和out的实质 JavaScript substr() 和 substring() 方法的区别 武林外传搞笑语录 调试和跟踪 VS2005单元测试[转] 几个.Net开源的CMS、Portal系统 DataKeyNames工作 查询后,翻页问题的解决办法2。(GridView1.PageIndex = e.NewPageIndex;) (转)
几条相关SQL语句
牵牛望岳 · 2008-11-07 · via 博客园 - 牵牛望岳

1、说明:复制表(只复制结构,源表名:a 新表名:b)(Access可用)

法一:select * into b from a where 1<>1

法二:select top 0 * into b from a

2、说明:一条SQL语句搞定数据库分页

select top 10 b. * from (select top 20 主键字段,排序字段 from 表名 order by 排序字段 desc) a,表名 b where b.主键字段 = a.主键字段 oredr by a.排序字段

3、说明:前10条记录

select top 10 * from table1 where 范围

4、说明:随机取出10条数据

select top 10 * from tablename order by newid() 

5、说明:选择从10到15的记录

select top 5 * from (select top 15 * from table order by id asc) table_别名order by id desc

6、SQL left()函数、len()函数

LEFT()   返回从字符串左边开始指定个数的字符(而不是字节).  

select   left(name,10)   from   member        
  如果name="123456中国910"  
  返回值是“123456中国91"  

len()函数统计的是字符(而不是字节)的个数

table   a    
  id     name  
  1       abc  
  2       张三  
  通过sql   查询,select   len(name)   from   a   得到如下结果:  
  1     3  
  2     2