SQL´æ´¢¹ý³Ì·ÖÒ³Ëã·¨Ñо¿(Ö§³ÖǧÍò¼¶)
SQL´æ´¢¹ý³Ì·ÖÒ³Ëã·¨Ñо¿(Ö§³ÖǧÍò¼¶)
1.“¶íÂÞ˹´æ´¢¹ý³Ì”µÄ¸ÄÁ¼°æ
CREATE procedure pagination1
(@pagesize int, --Ò³Ãæ´óС£¬Èçÿҳ´æ´¢20Ìõ¼Ç¼
@pageindex int --µ±Ç°Ò³Âë)
as set nocount on
begin
declare @indextable table(id int identity(1,1),nid int) --¶¨Òå±í±äÁ¿
declare @PageLowerBound int --¶¨Òå´ËÒ³µÄµ×Âë
declare @PageUpperBound int --¶¨Òå´ËÒ³µÄ¶¥Âë
set @PageLowerBound=(@pageindex-1)*@pagesize
set @PageUpperBound=@PageLowerBound+@pagesize
set rowcount @PageUpperBound
insert into @indextable(nid) select gid from TGongwen where fariqi >dateadd(day,-365,getdate()) order by fariqi desc
select O.gid,O.mid,O.title,O.fadanwei,O.fariqi from TGongwen O,@indextable t where O.gid=t.nid
and t.id>@PageLowerBound and t.id <=@PageUpperBound order by t.id
end
set nocount off
ÎÄÕÂÖеĵãÆÀ£º
ÒÔÉÏ´æ´¢¹ý³ÌÔËÓÃÁËSQLSERVERµÄ×îм¼Êõ¨D¨D±í±äÁ¿¡£Ó¦¸Ã˵Õâ¸ö´æ´¢¹ý³ÌÒ²ÊÇÒ»¸ö·Ç³£ÓÅÐãµÄ·ÖÒ³´æ´¢¹ý³Ì¡£µ±È»£¬ÔÚÕâ¸ö¹ý³ÌÖУ¬ÄúÒ²¿ÉÒÔ°ÑÆäÖеıí±äÁ¿Ð´³ÉÁÙʱ±í£ºCREATE TABLE #Temp¡£µ«ºÜÃ÷ÏÔ£¬ÔÚSQLSERVERÖУ¬ÓÃÁÙʱ±íÊÇûÓÐÓñí±äÁ¿¿ìµÄ¡£ËùÒÔ±ÊÕ߸տªÊ¼Ê¹ÓÃÕâ¸ö´æ´¢¹ý³Ìʱ£¬¸Ð¾õ·Ç³£µÄ²»´í£¬ËÙ¶ÈÒ²±ÈÔÀ´µÄADOµÄºÃ¡£µ«ºóÀ´£¬ÎÒÓÖ·¢ÏÖÁ˱ȴ˷½·¨¸üºÃµÄ·½·¨¡£
´Ó¸Ð¾õÉϽ²£¬Ð§Âʲ»ÊÇÌ«¸ß¡£
2. not in µÄ·½·¨£º
´Ópublish ±íÖÐÈ¡³öµÚ n Ìõµ½µÚ m ÌõµÄ¼Ç¼£º
SELECT TOP m-n+1 * from publish WHERE (id NOT IN (SELECT TOP n-1 id from publish))
id Ϊpublish ±íµÄ¹Ø¼ü×Ö
ÎÄÕÂÖеĵãÆÀ£º
ÎÒµ±Ê±¿´µ½ÕâƪÎÄÕµÄʱºò£¬ÕæµÄÊǾ«ÉñΪ֮һÕñ£¬¾õµÃ˼··Ç³£µÃºÃ¡£µÈµ½ºóÀ´£¬ÎÒÔÚ×÷°ì¹«×Ô¶¯»¯ÏµÍ³£¨ASP.NET+ C#£«SQLSERVER£©µÄʱºò£¬ºöÈ»ÏëÆðÁËÕâƪÎÄÕ£¬ÎÒÏëÈç¹û°ÑÕâ¸öÓï¾ä¸ÄÔìһϣ¬Õâ¾Í¿ÉÄÜÊÇÒ»¸ö·Ç³£ºÃµÄ·ÖÒ³´æ´¢¹ý³ÌÓÚÊÇÎÒ¾ÍÂúÍøÉÏÕÒÕâƪÎÄÕ£¬Ã»Ïëµ½£¬ÎÄÕ»¹Ã»ÕÒµ½£¬È´ÕÒµ½ÁËһƪ¸ù¾Ý´ËÓï¾äдµÄÒ»¸ö·ÖÒ³´æ´¢¹ý³Ì£¬Õâ¸ö´æ´¢¹ý³ÌÒ²ÊÇÄ¿Ç°½ÏΪÁ÷ÐеÄÒ»ÖÖ·ÖÒ³´æ´¢¹ý³Ì¡£
ʹÓÃÁË not in ¶ø not in ÊÇÎÞ·¨Ê¹ÓÃË÷ÒýµÄ£¬ËùÒÔ´ÓЧÂÊÉϽ²»¹ÊDzîÁËÒ»µã¡£
3. max µÄ·½·¨£º
select top Ò³´óС * from table1 where id>
(select max (id) from
(select top ((Ò³Âë-1)*Ò³´óС) id from table1 order by id) as T)
order by id
ÎÄ
Ïà¹ØÎĵµ£º
/*»ñÈ¡Öظ´¼Ç¼ÖнÏСµÄÄǸöID*/ create table tmp_Repeat as select min(id) as id from poi group by idcode having count(*) >1; /*±¸·Ýɾ³ýµÄÊý¾Ý*/ select * from poi where id in (select id from tmp_repeat) /*ɾ³ýÖظ´¼Ç¼ÖÐID½ÏСµÄÄÇÌõ
select replace('°¢¹ðÊǸöºÃº¢×Ó','°¢¹ð','СÏÍ') from du ......
jspÁ¬½Ósql server2005
£¨¾²âÊÔÁ¬½Ó³É¹¦£©
½Ó´¥Java»òÕßJSP£¬ÄÑÃâ»áʹÓõ½Êý¾Ý¿â
SQL Server
2000/2005£¨ÎÒʹÓÃ2005±ê×¼°æ[9.0.3054]²âÊÔ£©£¬¾¹ý×Ô¼ºµÄËÑË÷ºÍÑо¿£¬Ê¹ÓÃJDBCÁ¬½ÓSQL
Server³É¹¦£¬ÌØ´ËÕûÀí·½·¨£¨Ê¹ÓÃEclipse 3.2£©ÈçÏ¡£
×¼±¸¹¤×÷
Ê×ÏÈ£¬²Ù×÷ϵͳ
Öа²×°ºÃSQL Server
2000/2005£¬È ......
SQLµ÷ÓÅ Ö® Á¬½Ó·½Ê½
JoinÊÇÒ»ÖÖÊÔͼ½«Á½¸ö±í½áºÏÔÚÒ»ÆðµÄν´Ê£¬Ò»´ÎÖ»ÄÜÁ¬½Ó2¸ö±í£¬±íÁ¬½ÓÒ²¿ÉÒÔ±»³ÆΪ±í¹ØÁª¡£ÔÚºóÃæµÄÐðÊöÖУ¬Ê¹ÓÔrow source”À´´úÌ攱픣¬ÒòΪʹÓÃrow source¸üÑϽ÷һЩ£¬²¢ÇÒ½«²ÎÓëÁ¬½ÓµÄ2¸örow source·Ö±ð³ÆΪrow source1ºÍrow source 2¡£Join¹ý³ÌµÄ¸÷¸ö²½Öè¾³£ÊÇ´®ÐвÙ×÷ ......
SQLÖÐDATEADDºÍDATEDIFFµÄÓ÷¨
ÈÕÆÚ:2008-07-17 ×÷Õß:ϲ騰С¶þ 來Ô´:PHPChina
ͨ³££¬妳ÐèÒª獲µÃ當Ç°ÈÕÆÚºÍ計ËãһЩÆäËûµÄÈÕÆÚ£¬ÀýÈ磬妳µÄ³ÌÐò¿ÉÄÜÐèÒªÅÐ斷Ò»個ÔµĵÚÒ»Ìì»òÕß×îááÒ»Ìì¡£妳們´ó²¿·ÖÈË´ó¸Å¶¼ÖªµÀÔõ樣°ÑÈÕÆÚ進ÐзָÄê ......