随机读取几条文章的sql写法

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/coolwu/article/details/70153525
access数据库这样写:

Randomize
sq="select top 5 * from text1 order by rnd(-(id+" & rnd() & "))"
select top 10 * from table order by rnd(id)
select top 10 * from table order by rnd(id-timer())

mssql数据库这样写:

sql="select top 5 * from text1 order by newid()"
展开阅读全文

几条SQL语句

12-06

表1结构如下:rnrun_id prcs_id use_id diliver_time flow_id end_timern231 1 45467 2011-09-14 15:47:00 1 nullrn231 2 67676 2011-09-14 16:35:12 1 nullrn231 3 67676 null 1 nullrn235 1 45467 null 3 nullrn235 2 67376 2011-11-14 16:35:12 3 nullrn235 3 45554 2011-11-07 11:06:57 3 nullrn235 4 45454 null 3 nullrn238 8 45454 2011-11-07 11:06:27 6 nullrn239 3 46554 2011-11-07 11:06:57 6 2011-11-07 13:06:57rn239 4 46454 2011-11-07 12:06:57 6 2011-11-07 13:06:57rn239 5 25454 2011-11-07 13:06:57 6 2011-11-07 13:06:57rn236 1 35467 2011-11-17 15:47:00 7 2011-11-22 13:06:57rn236 2 67376 2011-11-19 16:35:12 7 2011-11-22 13:06:57rn236 3 46d54 2011-11-20 11:06:57 7 2011-11-22 13:06:57rn236 4 46c54 2011-11-21 12:06:57 7 2011-11-22 13:06:57rn236 5 25454 2011-11-22 13:06:57 7 2011-11-22 13:06:57rn266 1 25654 2011-11-22 16:06:57 8 nullrn996 1 35467 2011-01-17 15:47:00 3 nullrn996 2 67376 2011-11-19 16:35:12 3 nullrnrn1.我想查找出diliver_time字段为1那行数据,结果如下:rn结果1:rnrun_id prcs_id use_id diliver_time flow_id end_timern266 1 25654 2011-11-22 16:06:57 8 nullrn2、我想把prcs_id列单独为1出现的数据全部过滤掉rn结果2:rnrun_id prcs_id use_id diliver_time flow_id end_timern231 1 45467 2011-09-14 15:47:00 1 nullrn231 2 67676 2011-09-14 16:35:12 1 nullrn231 3 67676 null 1 nullrn235 1 45467 null 3 nullrn235 2 67376 2011-11-14 16:35:12 3 nullrn235 3 45554 2011-11-07 11:06:57 3 nullrn235 4 45454 null 3 nullrn238 8 45454 2011-11-07 11:06:27 6 nullrn239 3 46554 2011-11-07 11:06:57 6 2011-11-07 13:06:57rn239 4 46454 2011-11-07 12:06:57 6 2011-11-07 13:06:57rn239 5 25454 2011-11-07 13:06:57 6 2011-11-07 13:06:57rn236 1 35467 2011-11-17 15:47:00 7 2011-11-22 13:06:57rn236 2 67376 2011-11-19 16:35:12 7 2011-11-22 13:06:57rn236 3 46d54 2011-11-20 11:06:57 7 2011-11-22 13:06:57rn236 4 46c54 2011-11-21 12:06:57 7 2011-11-22 13:06:57rn236 5 25454 2011-11-22 13:06:57 7 2011-11-22 13:06:57rn996 1 35467 2011-01-17 15:47:00 3 nullrn996 2 67376 2011-11-19 16:35:12 3 nullrn3、我想把prcs_id列单独为不连续出现(比如1,2,3……)的那组(相同run_id)数据全部过滤掉rn结果3:rnrun_id prcs_id use_id diliver_time flow_id end_timern231 1 45467 2011-09-14 15:47:00 1 nullrn231 2 67676 2011-09-14 16:35:12 1 nullrn231 3 67676 null 1 nullrn235 1 45467 null 3 nullrn235 2 67376 2011-11-14 16:35:12 3 nullrn235 3 45554 2011-11-07 11:06:57 3 nullrn235 4 45454 null 3 nullrn236 1 35467 2011-11-17 15:47:00 7 2011-11-22 13:06:57rn236 2 67376 2011-11-19 16:35:12 7 2011-11-22 13:06:57rn236 3 46d54 2011-11-20 11:06:57 7 2011-11-22 13:06:57rn236 4 46c54 2011-11-21 12:06:57 7 2011-11-22 13:06:57rn236 5 25454 2011-11-22 13:06:57 7 2011-11-22 13:06:57rn996 1 35467 2011-01-17 15:47:00 3 nullrn996 2 67376 2011-11-19 16:35:12 3 nullrn3、我想把prcs_id列单独为一行那组(相同run_id)数据全部过滤掉rn结果4:rnrun_id prcs_id use_id diliver_time flow_id end_timern231 1 45467 2011-09-14 15:47:00 1 nullrn231 2 67676 2011-09-14 16:35:12 1 nullrn231 3 67676 null 1 nullrn235 1 45467 null 3 nullrn235 2 67376 2011-11-14 16:35:12 3 nullrn235 3 45554 2011-11-07 11:06:57 3 nullrn235 4 45454 null 3 nullrn239 3 46554 2011-11-07 11:06:57 6 2011-11-07 13:06:57rn239 4 46454 2011-11-07 12:06:57 6 2011-11-07 13:06:57rn239 5 25454 2011-11-07 13:06:57 6 2011-11-07 13:06:57rn236 1 35467 2011-11-17 15:47:00 7 2011-11-22 13:06:57rn236 2 67376 2011-11-19 16:35:12 7 2011-11-22 13:06:57rn236 3 46d54 2011-11-20 11:06:57 7 2011-11-22 13:06:57rn236 4 46c54 2011-11-21 12:06:57 7 2011-11-22 13:06:57rn236 5 25454 2011-11-22 13:06:57 7 2011-11-22 13:06:57rn996 1 35467 2011-01-17 15:47:00 3 nullrn996 2 67376 2011-11-19 16:35:12 3 nullrn 论坛

关于txt文件的随机读取

12-09

我想对一个TXT文件实现随机读写,必须用到文件指针,seek()函数来操纵读写开始的位置。rn考虑用RanderAccessFile类,虽然可以使用seek操纵光标,但是由于该类是对文件按字节读取,所以就不能正常显示中文字符。rnrn考虑组合使用以下三个类:FileInputStream InputStreamReader BufferedReader虽然可以正常显示中文字符,但有缺少了seek操纵光标的方便。rnrn请问有无解决的好办法。rnrn还有就是我的目标文档格式为rnrn单位名称:南京汇丰尼龙有限公司rn地 址:江苏省南京市朝天宫西街57号4-2-101室rn邮 编:210004rn传 真:025-86502194rn电 话:025-86655359rn主要产品:尼龙切片750吨/年rn设备情况: VK管1套,1000L聚合釜2套,固相反应聚合釜2套。  rnrn单位名称:南京化纤股份有限公司rn地 址:江苏省南京市高新技术开发区20幢B二楼rn邮 编:210038rn传 真:025-85562252rn电 话:025-85562819 85561081 85561280rn电子邮箱:office@viscosefibre.comrn网 址:www.viscosefibre.comrn主要产品: 化纤浆粕20000吨/年,金羚牌;粘胶长丝5000吨/年,金羚牌;粘胶短纤15000吨/年,金羚牌。 rn设备情况: R531纺丝机80台及其后处理、加工配套设备;HR401 纺丝机2台及 其配套的两条短纤生产线;R165黄化机19台;R122高温老成鼓3台;R123高温老成鼓1台;R5 35A丝机36台;R701络丝机34台。rn .rn .rn .rnrn我想显示空行以上的内容,编码如下:rnimport java.io.*;rnpublic class examFile8rn public static void main(String arg[])rn FileInputStream fileInStream;rn InputStreamReader inputReader;rn BufferedReader bufReader;rn tryrn fileInStream = new FileInputStream("e:\\mydir\\中国化纤企业名录江苏部分.txt");rn inputReader = new InputStreamReader(fileInStream);rn bufReader = new BufferedReader(inputReader);rn String lineStr;rn String aa = "\r";rn while((lineStr = bufReader.readLine())!=null||lineStr.matches(aa)==false)rn System.out.println(lineStr);rn rn catch(FileNotFoundException e)rn catch(IOException e)rn rnrnrn显示老是滚屏,停不下来,怎么在空行处截住显示?rnrn谢谢大家rn 论坛

没有更多推荐了,返回首页