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

sql²éѯѡÔñ±íÖдÓ10µ½15µÄ¼Ç¼

      ORDER BY ×Ӿ䰴һÁлò¶àÁУ¨×î¶à 8,060 ¸ö×Ö½Ú£©¶Ô²éѯ½á¹û½øÐÐÅÅÐò¡£ÓÐ¹Ø ORDER BY ×Ó¾ä×î´ó´óСµÄÏêϸÐÅÏ¢£¬Çë²ÎÔÄ ORDER BY ×Ó¾ä (Transact-SQL)¡£
      Microsoft SQL Server 2005 ÔÊÐíÔÚ from ×Ó¾äÖÐÖ¸¶¨¶Ô SELECT ÁбíÖÐδָ¶¨µÄ±íÖеÄÁнøÐÐÅÅÐò¡£ORDER BY ×Ó¾äÖÐÒýÓõÄÁÐÃû±ØÐëÃ÷È·µØ¶ÔÓ¦ÓÚ SELECT ÁбíÖеÄÁлò from ×Ó¾äÖеıíÖеÄÁС£Èç¹ûÁÐÃûÒÑÔÚ SELECT ÁбíÖÐÓÐÁ˱ðÃû£¬Ôò ORDER BY ×Ó¾äÖÐÖ»ÄÜʹÓñðÃû¡£Í¬Ñù£¬Èç¹û±íÃûÒÑÔÚ from ×Ó¾äÖÐÓÐÁ˱ðÃû£¬Ôò ORDER BY ×Ó¾äÖÐÖ»ÄÜʹÓñðÃûÀ´ÏÞ¶¨ËüÃǵÄÁС£
ÅÅÐò¿ÉÒÔÊÇÉýÐòµÄ (ASC)£¬Ò²¿ÉÒÔÊǽµÐòµÄ (DESC)¡£Èç¹ûδָ¶¨ÊÇÉýÐò»¹ÊǽµÐò£¬¾Í¼Ù¶¨Îª ASC¡£
SELECT
[USER_ID],[USER_NAME],[USER_EMAIL],[USER_PASSWORD]
from users where [USER_EMAIL] is not null and [USER_PASSWORD] is not null
--˵Ã÷£ºÑ¡Ôñ´Ó11µ½15µÄ¼Ç¼
select top 5
[USER_ID],[USER_NAME],[USER_EMAIL],[USER_PASSWORD]
from (select top 15 [USER_ID],[USER_NAME],[USER_EMAIL],[USER_PASSWORD] from users
order by [USER_ID] asc) users2
where [USER_EMAIL] is not null and [USER_PASSWORD] is not null order by [USER_ID] desc

ÉÏÊöÓï¾ä
(select top 15 [USER_ID],[USER_NAME],[USER_EMAIL],[USER_PASSWORD] from users
order by [USER_ID] asc) users2
±íʾ½«Ç°Êý¾Ý¿âµÄÇ°15Ìõ¼Ç¼°´ÄæÐòÅÅÁУ¬´æ·ÅÔÚ±ðÃûΪuser2µÄ±íÖС£
È»ºóÔÙͨ¹ý
select top 5
À´Ñ¡³öÇ°5Ìõ¼Ç¼£¬ÒòΪuser2ÊÇ°´ÄæÐòÅÅÁеģ¬ËùÒÔ×îºó½á¹ûÊÇ´ÓµÚ15-11ÌõµÄ¼Ç¼¡£
¸üÐÂ
Èçϲéѯ´úÂëËùʾ£¬ÎÒÃÇ¿ÉÒÔ¿´µ½ÓÐÒ»ÐеÄwhere±»×¢ÊÍÁË£¬ÕâÊÇÒòΪÔÚÈ«ÃæµÄ²éѯ¼¯ÖÐÒѾ­È¥µôÁ˲»·ûºÏÒªÇóµÄÄÚÈÝÁË£¬ºóÃæ¾Í²»ÐèÒªÔÙÓÃwhereÀ´ÏÞ¶¨¡£´úÂë×¢ÊÍ»¹¸ø³öÁËÊ×Ä©ÊýµÄ¼ÆËã·½·¨¡£
--µÚ¶þ¸öÊý-µÚÒ»¸öÊý+1¿ªÊ¼£¬µ½µÚ¶þ¸öÊýλÖÃ
--´Ó7001¿ªÊ¼£¬µ½11828Ϊֹ¡£µÃ³öµÚÒ»¸öÊý£¬11828-x+1=7001,x=4828
SELECT top 4828
'<User>'+
'<Username>' + [USER_NAME] + '</Username>',
'<Email>' + [USER_EMAIL] + '</Email>',
'<Password>' + [USER_PASSWORD] + '</Password>' +
'</User>'
from (select top 11828 [USER_ID],[USER_NAME],[USER_EMAIL],[USER_PASSWORD] from users
where [USER_EMAIL] is not nul


Ïà¹ØÎĵµ£º

SQL 2005 ASP.NETÊý¾Ý¿âÁ¬½Ó×ܽá

 
VS2005+SQL2005 ASP.NET2.0Êý¾Ý¿âÁ¬½Ó×ܽá
    Í¨¹ýÉÏƪÎÄÕ£¨http://www.cnblogs.com/user34j/archive/2007/01/23/628426.html£©µÄÉèÖÃÆäʵÒѾ­²î²»¶àÍê³ÉÁË£¬Ö»ÊÇ»¹ÓÐһЩϸ½ÚµÄµØ·½Ã»ÓÐ×öºÃ£¬¾­¹ýÒ»·¬Ñо¿ÏÖÔÚÖÕÓڸ㶨ÁË¡£¶ÔÓÚÏñÎÒÕâÑùµÄÐÂÊÖÀ´Ëµ£¬Õû¸öÊý¾Ý¿âÁ¬½ÓÕæÊDz»ÈÝÒס£ÏÖ×ܽáÈçÏ£ ......

SQL_²éѯµ±Ìì¡¢½ü¼¸Ìì¡¢±¾ÖÜ¡¢±¾ÔµÄSQLÓï¾ä

¾­³£»áÓÐʱºòÒªÓõ½²éѯµ±Ì죬½ü¼¸Ì죬±¾ÖÜ£¬±¾ÔµÄÏà¹ØÊý¾Ý£¬ËùÒԼǼһÏÂÕâЩ±È½ÏÌØÊâµÄSQLÓï¾ä~~
--µ±Ìì
(usrRegTime >=CONVERT(varchar(10),getDate(),120)+' 00:00:00' and usrRegTime <=CONVERT(varchar (10),getDate(),120)+' 23:59:59')
--½üÈýÌì
DateDiff(day,usrRegTime,getdate()) <=3
--±¾ÖÜ ......

SQLÓï¾ä¸´ÖƱíµÄ·½·¨


SQLÓï¾ä¸´ÖƱíµÄ·½·¨
(2009-08-29 13:41:54)
±êÇ©£º
sql
·ÖÀࣺ¼ÆËã»ú֪ʶ
Èç¹ûÄ¿µÄ±íÒѾ­´æÔÚ:
insert into DATAHR.DBO.GBITEM
select * from DEMO.DBO.GBITEM
Èç¹ûÄ¿µÄ±í²»´æÔÚ:
select * into DATAHR.DBO.GBITEM
from DEMO.DBO.GBITEM
¿ç¿âµ¼Èë
select * into [zk_news].[dbo].[News1] from [zk_media].[ ......

ÎÄ˼´´ÐµÄSQL±ÊÊÔÌâ


ÌâÄ¿£ºÓÐAºÍBÁ©¸ö±í£¬¶¼¶¨ÒåÏàͬµÄÖ÷¼ü£¬Ð´³öSQLÓï¾äÕÒ³öA±íÖÐÓжøB±íÖÐûÓеļǼ£¬È»ºó°ÑûÓеļǼ²åÈëµ½B±íÖС£
SQLÓï¾äÈçÏ£º
CREATE TABLE  A_MINUS_B  AS              ---´´½¨Ò»¸ö²î¼¯±íA_MINUS_B ,×¢ÒâSELECT Óï¾äÒ»¶¨ÒªA±íÔÚÇ°¡ ......

sql2005ÖÐÒ»¸öxml¾ÛºÏµÄÀý×Ó

sql2005ÖÐÒ»¸öxml¾ÛºÏµÄÀý×Ó ÊÕ²Ø
¸ÃÎÊÌâÀ´×ÔÂÛ̳ÌáÎÊ£¬ÑÝʾSQL´úÂëÈçÏÂ
--½¨Á¢²âÊÔ»·¾³
set nocount on
create table test(ID varchar(20),NAME varchar(20))
insert into test select '1','aaa'
insert into test select '1','bbb'
insert into test select '1','ccc'
insert into test select '2','ddd'
inser ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ