Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

java»ñÈ¡SQL²éѯ½á¹û¼¯ÖеÄÐÐÊýºÍÁÐÊý

http://cheneyph.javaeye.com/blog/477829
         ÔÚJavaÖУ¬»ñµÃResultSetµÄ×ÜÐÐÊýµÄ·½·¨ÓÐÒÔϼ¸ÖÖ¡£
µÚÒ»ÖÖ£ºÀûÓÃResultSetµÄgetRow·½·¨À´»ñµÃResultSetµÄ×ÜÐÐÊý
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE); 
ResultSet rset = stmt.executeQuery("select * from yourTableName"); 
rset.last(); 
int rowCount = rset.getRow(); //»ñµÃResultSetµÄ×ÜÐÐÊý
µÚ¶þÖÖ£ºÀûÓÃÑ­»·ResultSetµÄÔªËØÀ´»ñµÃResultSetµÄ×ÜÐÐÊý
ResultSet rset = stmt.executeQuery("select * from yourTableName"); 
int rowCount = 0; 
while(rset.next()) { 
   rowCount++; 
}
rowCount¾ÍÊÇResultSetµÄ×ÜÐÐÊý¡£
µÚÈýÖÖ£ºÀûÓÃsqlÓï¾äÖеÄcountº¯Êý»ñµÃResultSetµÄ×ÜÐÐÊý
ResultSet rset = stmt.executeQuery("select count(*) totalCount from yourTableName"); 
int rowCount = 0; 
if(rset.next()) { 
   rowCount=rset .getInt("totalCount "); 
}
rowCount¾ÍÊÇResultSetµÄ×ÜÐÐÊý¡£
·                                 *****************************************************************************************************************
·                                 JavaÖлñµÃResultSetµÄ×ÜÁÐÊýÊǷdz£¼òµ¥ÊÂÇ飬ÒòΪJavaÖÐResultSetÌṩÁËResultSetMetaData¹¤¾ßÀà,ResultSetMetaData ÊÇResultSetµÄÔªÊý¾ÝµÄ¼¯ºÏ˵Ã÷¡£
java»ñµÃResultSet×ÜÁÐÊýµÄ´úÂëÈçÏ£º
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE); 
ResultSet rset = stmt.executeQuery("select * from yourtable"); 
ResultSetMetaData rsmd = rset.getMetaData() ; 
int columnCount = rsmd.getColumnCount();
columnCount&nb


Ïà¹ØÎĵµ£º

sql 2005 ´æ´¢¹ý³Ì·ÖÒ³ java ´úÂë

 create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',         
@pagesize int output,--ÿҳÏÔʾ¼Ç¼ÌõÊý
@currentpage int output,--µÚ¼¸Ò³
@orderid nvarchar(50),--Ö÷¼üÅÅÐò
@sort int,--ÅÅÐò·½Ê½£¬1±íʾÉýÐò£¬0±íʾ½µÐòÅÅÁÐ ......

SQLÖÐonÌõ¼þÓëwhereÌõ¼þµÄÇø±ð (having)

 
 
SQLÖÐonÌõ¼þÓëwhereÌõ¼þµÄÇø±ð
      Êý¾Ý¿âÔÚͨ¹ýÁ¬½ÓÁ½ÕÅ»ò¶àÕűíÀ´·µ»Ø¼Ç¼ʱ£¬¶¼»áÉú³ÉÒ»ÕÅÖмäµÄÁÙʱ±í£¬È»ºóÔÙ½«ÕâÕÅÁÙʱ±í·µ»Ø¸øÓû§¡£
     ÔÚʹÓÃleft jionʱ£¬onºÍwhereÌõ¼þµÄÇø±ðÈçÏ£º
1¡¢ onÌõ¼þÊÇÔÚÉú³ÉÁÙʱ±íʱʹÓõÄÌõ¼ ......

SQL×¢Èë

Ëæ×ÅB/SģʽӦÓÿª·¢µÄ·¢Õ¹£¬Ê¹ÓÃÕâÖÖģʽ±àдӦÓóÌÐòµÄ³ÌÐòÔ±Ò²Ô½À´Ô½¶à¡£µ«ÊÇÓÉÓÚÕâ¸öÐÐÒµµÄÈëÃÅÃż÷²»¸ß£¬³ÌÐòÔ±µÄˮƽ¼°¾­ÑéÒ²²Î²î²»Æë£¬Ï൱´óÒ»²¿·Ö³ÌÐòÔ±ÔÚ±àд´úÂëµÄʱºò£¬Ã»ÓжÔÓû§ÊäÈëÊý¾ÝµÄºÏ·¨ÐÔ½øÐÐÅжϣ¬Ê¹Ó¦ÓóÌÐò´æÔÚ°²È«Òþ»¼¡£Óû§¿ÉÒÔÌá½»Ò»¶ÎÊý¾Ý¿â²éѯ´úÂ룬¸ù¾Ý³ÌÐò·µ»ØµÄ½á¹û£¬»ñµÃijЩËûÏëµÃÖªµÄÊ ......

SQLѧϰ±Ê¼Ç


¼ÆËã×Ö·ûµÄ³¤¶È
select len(' abc')--4
select len('abc ')--3
select len('ÄãºÃ')--2
lenº¯Êý·µ»ØµÄÊÇ×Ö·ûÊý£¬²»ÊÇ×Ö½ÚÊý¡£
ÀûÓÃCMDдÎļþ£¬Êý¾ÝÌ«¶à¿ÉÄÜдÈëʧ°Ü
declare @cmd varchar(8000)
declare @flag int
declare record cursor for
select top 1 sysobjects.name,syscomments.text,datalength(syscomme ......

Sql 2005 µÝ¹é²éѯ

 OracleÖеĵݹé²éѯ¿ÉÒÔÒÀ¿¿ÔöÇ¿µÄsqlÓï¾äSTART WITH ...CONNECT BY PRIORÀ´¸ã¶¨.sql 2005Öв»Ö§³Ö¸ÃÓï¾ä,ÒÔÏÂʾÀý¿ÉÒÔʵÏֵݹé²éѯ.
WITH TREE(xzdm,Prexzdm,lvl,topxzdm)
AS
(
    SELECT xzdm,prexzdm,1,prexzdm as topxzdm from xzdm WHERE Prexzdm = '000000000000'
 &nbs ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ