Discuz!NT 3.0 SQL×¢È멶´
·¢±íϱ¾È˽øÐЩ¶´ÍÚ¾òµÄÊ×ƪԴ´ÎÄÕ£º
¶ÔDiscuz nT3.0½øÐÐÁË·ÖÎö£¬·¢ÏÖspacemanage.aspxÒ³Ãæ´æÔÚÒ»¸ö×¢È멶´£¬
¸ÃÒ³ÃæλÖãºdnt3_src\dnt3\Discuz.Web\space\Admin
´úÂëÈçÏ£º
public void BindData()
{
DataGrid1.AllowCustomPaging = true;
string username = Username.Text;
//string dateStart = joindateStart.SelectedDate.ToString().IndexOf("1900") >= 0 ? "" : joindateStart.SelectedDate.ToString();
//string dateEnd = joindateEnd.SelectedDate.AddDays(1).ToString().IndexOf("1900") >= 0 ? "" : joindateEnd.SelectedDate.AddDays(1).ToString();
string dateStart = joindateStart.SelectedDate.ToString();
string dateEnd = joindateEnd.SelectedDate.AddDays(1).ToString().IndexOf("1900") >= 0 ? DateTime.Now.AddDays(1).ToString() : joindateEnd.SelectedDate.AddDays(1).ToString();
DataGrid1.VirtualItemCount = DbProvider.GetInstance().GetSpaceRecordCount(username, dateStart, dateEnd);
DataGrid1.DataSource = buildGridData(username,dateStart,dateEnd);
DataGrid1.DataBind();
}
¶ÔUSERNAME ½øÐиú×Ù£¬·¢ÏÖδ¶Ô¸Ã²ÎÊý½øÐÐÈκιýÂË¡£´æÔÚSQL×¢È멶´¡£
±¾ÈËδ¶Ô¸Ã©¶´½øÐвâÊÔ£¬Èç¹ûÓÐÈ˲âÊÔÍêÖ¤Ã÷ȷʵ´æÔÚÇ뼰ʱÁªÏµ¹Ù·½¡£
ÁíÍ⣬תÌùÇë×¢Ã÷³ö´¦¡£
Ïà¹ØÎĵµ£º
SQLλÔËËã
select 2|8 --10
select 2|8|1 --11
select 10&8 --8,°üº¬,10=8+2
select 10&2 --2,°üº¬,10=2+8
select 10&4 --0,²»°üº¬
select 19&16 --16,°üº¬,19=16+2+1
s ......
Cross Applyʹ±í¿ÉÒԺͱíÖµº¯Êý½á¹û½øÐÐjoin, ÕâÑù±íÖµº¯ÊýµÄ²ÎÊý¾Í¿ÉÒÔʹÓÃÒ»¸ö½á¹û¼¯£¬¶ø²»ÊÇÒ»¸ö±êÁ¿Öµ£¬ÏÂÃæÊÇbook onlineµÄÔÎÄ£¬ÓÐÀý×Ó£¬ÓнâÊÍ¡£
The APPLY operator allows you to invoke a table-valued function for each row returned by an outer table expression of a query. The table-valued function act ......
MySQL:
SELECT column from table
ORDER BY RAND()
LIMIT 1
PostgreSQL:
SELECT column from table
ORDER BY RANDOM()
LIMIT 1
Microsoft SQL Server:
SELECT TOP 1 column from table
ORDER BY NEWID()
IBM DB2
SELECT column, RAND() as IDX
from table
ORDER BY IDX FETCH FIRST 1 ROWS ONLY
Thanks Ti ......
Ó¦Ò»¸öÅóÓѵÄÒªÇó£¬ÌùÉÏÊղصÄSQL³£Ó÷ÖÒ³µÄ°ì·¨¡«¡«
±íÖÐÖ÷¼ü±ØÐëΪ±êʶÁУ¬[ID] int IDENTITY (1,1)
1.·ÖÒ³·½°¸Ò»£º(ÀûÓÃNot InºÍSELECT TOP·ÖÒ³)
Óï¾äÐÎʽ£º
SELECT TOP Ò³¼Ç¼ÊýÁ¿ *
from ±íÃû
WHERE (ID NOT IN
(SELECT TOP (ÿҳÐÐÊý*(Ò³Êý-1)) ID
from ± ......