ÇóÖú£ºSQL Server²éѯ - MS-SQL Server / ÒÉÄÑÎÊÌâ
Á½¸ö±í£¬Ò»¸ö»áÔ±±í£¬Ò»¸öÏû·Ñ¼Ç¼±í¡£ÐèÒª²éµÄÊÇ×î½üÏû·ÑµÄ»áÔ±£¬È»ºó»áÔ±±íͨ¹ýÏû·Ñʱ¼äµ¹ÐòÅÅÐò¡£ÇóÖú´ó¼ÒÔõô×ö¡£ÎÒ´òËãÏÈ·Ö×飬ͳ¼Æ¿¨»áÔ±µÄ¸öÊý£¬È»ºóÔÚͨ¹ýÏû·Ñ±íÖеÄÏû·Ñʱ¼äÌõ¼þÅÅÐò£¬µ«ÕâÑùÅÅÐòÍêÈ«²»ÐС£ÇóÖú´ó¼Ò¸ÃÈçºÎ½â¾ö£¬Ð»Ð»£¡
¸ø³ö±íµÄ½á¹¹¡¢²âÊÔÊý¾Ý¡¢¼°½á¹û
×î½üµÄ·¶Î§½üµ½ÄÄÀÓÐûÓÐÃ÷È·µÄ·¶Î§
·¶Î§Ö»Êǵ¹Ðò¶øÒÑ¡£
»áÔ±±í£ºMember
Ïû·Ñ¼Ç¼±í£ºCashLog
Ïû·Ñ¼Ç¼ÖÐ×ÔÈ»±£³Ö×ŶàÌõµ¥¸ö»áÔ±ÐÅÏ¢£¬ÐèÒª²éѯ×î½üÏû·ÑÅÅÐòµÄÌõ¼þÏû·Ñʱ¼äTimeÊôÓÚCashLog±í¡£
SQL code:
SELECT a.»áÔ±Ãû, MAX(b.Ïû·Ñʱ¼ä) Ïû·Ñʱ¼ä
from »áÔ±±í a
JOIN Ïû·Ñ¼Ç¼±í b
ON a.»áÔ±ID = b.»áÔ±ID
GROUP BY a.»áÔ±Ãû
ORDER BY Ïû·Ñʱ¼ä DESC
SQL code:
select a.*,b.*
from »áÔ±±í a
left join Ïû·Ñ¼Ç¼±í b on a.»áÔ±ID=b.
Ïà¹ØÎÊ´ð£º
ÎÒÒ»¸öÏîÄ¿£¬Óиö²åÈë²Ù×÷£¬¾ßÌåÊÇÕâÑùµÄ£º
ÎÒÓнø»õÐÅÏ¢±í¡£ÔÚ³ö»õʱѡÔñÏàÓ¦µÄ½ø»õÐÅÏ¢£¬ÊäÈëÊýÁ¿£¬Ñ¡Ôñ²¿Ãź󣬵㱣´æ°´Å¥£¬ÓÉÓÚÍøÂçÑÓʱ£¬µãÒ»ÏÂûÓз´Ó³£¬ÓÚÊÇÓû§¾ÍÓÖµãһϣ¬µ¼ÖÂÒ»´Î²åÈëÁËÁ½Ìõ¼Ç¼:
Àý£º
......
ÏÖÔÚÓÐÁ½ÕÅ±í£ºÎÄÕÂÖ÷±íA(articleId,articleTitle)£¬ÎÄÕÂÆÀÂÛ±íB(commentId,articleId,commentTitle)
ÏÖÔÚÎÒÏëʵÏÖÕâÑùµÄ¹¦ÄÜ£ºÁгöÎÄÕÂÁÐ±í£¬ÆäÖÐÿƪÎÄÕ±êÌâÏÂÃæÁгö´ËÎÄÕµÄÇ°2¸öÎÄÕÂÆÀÂÛ£¬ÇëÎÊsqlÓï¾äÔõôд°¡ ......
ÕâÀïÏëÁ˽âÏ£¬¹ØÓÚSQL ServerÖзÖÒ³ºÍOracleÖзÖÒ³£»
ƽ³£Ð´Ó¦ÓóÌÐòµÄʱºò£¬±ÈÈçÓõÄÓïÑÔÊÇJava£¬ÓиöÁбíÒ³Ã棬ÐèÒª¶ÔÊý¾Ý·ÖÒ³ÏÔʾ£»
ÕâÀïÒª·ÖÒ³ÄѵÀ²»ÐèÒª½èÖúJava£¬¶øÖ±½ÓsqlÄÜÖªµÀ·ÖÒ³Âð£¬ÆðÂëÒ²Òª´«¸öÒ³Âë½ ......
Ôõô°ÑMDFÊý¾Ýתµ½MySQL£¿
ÖÁÉٵø½¼Óµ½sqlserverÉÏ
¾ßÌåÔõôŪ°¡ ÎҵıÏÒµÉè¼ÆµÄÊý¾Ý¿âÊÇ´ÓÍøÉÏdownÏÂÀ´µÄ£¿£¿
Ä㻹²»ÈçÖ±½ÓÓÃsqlserverÄØ
º¯Êý¡¢´æ´¢¹ý³Ì¶¼µÃ¸ÄÁË¡£
sqlserverûÔõôÓùý¡£Ò²Ã»Óа²× ......
¸÷λºÃ£¬ÎÒ¸Õ°ÑÒ»¸öASPÍøÕ¾ÉèÖúÃÁË£¬Ò²ÄÜÕý³£·ÃÎÊ¡£µ«ÊÇÔÚÎÒ±¾»úÉϲ»ÄÜ´ò¿ªadmin\login.asp,ËùÒÔÎÞ·¨ÊµÏÖºǫ́¹ÜÀí¡££¨´íÎóÌáʾÎÞ·¨ÕÒµ½ÍøÒ³£¬´úÂë404£¬ÎҵIJÙ×÷ϵͳÊÇwin2000 server)
µ«ÊÇÆæ¹ÖµÄÊÇÔÚ¾ÖÓòÍøµÄÆäËû» ......