Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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×¢Èë

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

fastreport´òÓ¡´úÂë¼°SQLºÏ²¢×ֶεÄÓï¾ä

 procedure Tform1.Button5Click(Sender: TObject);
var
  p:pointer;
  FrfStr:string;
begin
  inherited;
  Screen.Cursor:=MYCURSORWAITHAND;
  with cdsPrint do
  begin
    Active:=false;
    //Õâ¸öSQLÓÃÓÚ½«remarkÖеļǼºÏ²¢µ½Ò»Æ ......

SQL ͨÓô洢¹ý³Ì


using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
/// <summary>
/ ......

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 ½»²æ±í

½»²æ±íÓï¾äµÄʵÏÖ:
¡¡¡¡ÓÃÓÚ:½»²æ±íµÄÁÐÊýÊÇÈ·¶¨µÄ
¡¡¡¡select name,sum(case subject when 'Êýѧ' then source else 0 end) as 'Êýѧ',
¡¡¡¡sum(case subject when 'Ó¢Óï' then source else 0 end) as 'Ó¢Óï',
¡¡¡¡sum(case subject when 'ÓïÎÄ' then source else 0 end) as 'ÓïÎÄ'
¡¡¡¡from test
¡¡¡¡group by name ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ