¹ØÓÚsqlµÄÁ´½Ó²éѯ
Ê×Ïȸø³öÁ½ÕŲâÊÔ±í
a(aid int, adata varchar(20)) b(bid int, bdata varchar(20))
1.join Óë inner join
Ö´ÐÐÈçÏÂÓï¾ä£º
select * from a join b on a.aid = b.bid;
ÎÒÃÇ»áµÃµ½ÈçϵĽá¹û£º
AID ADATA BID BDATA
---------- ---------------------------------------- ---------- ----------------------------------------
1 a1 1 b1
2 a2 2 b2
ÎÒÃÇÔÚÖ´ÐУºselect * from a inner join b on a.aid = b.bid;
Õâʱ»á·¢ÏÖÖ´ÐеĽá¹ûºÍÉÏÃæÒ»Ñù£¬ÓÚÊÇÎÒÔÚÕâÀïÈÏΪ£¬µ¥Ð´Ò»¸öjoinµÄÓï¾ä£¬Ä¬ÈÏʹÓÃinnerÐÎʽÁ¬½Ó²éѯ¡£ÕâʱÎÒÒ²»áÏëµ½Óñê×¼µÄ¶à±í²éѯȥʵÏÖ£¬È磺select * from a, b where a.aid = b.bid¡£
ÉÏÃæÕâЩ¶¼ÊÇÔÚoracleºÍmysqlÖвâÊÔ¹ýµÄ£¬µ±È»ÏÂÃæËùÌáµ½µÄÒ²»á×öͬÑùµÄ²âÊÔ¡£
2.left join Óë left outer join
Ö´ÐÐÈçÏÂÓï¾ä£º
select * from a left join b on a.aid = b.bid;
µÃµ½µÄ½á¹ûÈçÏ£º
AID ADATA&
Ïà¹ØÎĵµ£º
Èç¹ûÎÒÃǵÄSQL ServerÒª±£Ö¤¸ß¿ÉÓÃÐÔ£¬ÄÇô¿ÉÒÔ²ÉÓùÊÕÏתÒÆȺ¼¯¡£×î¼òµ¥µÄ¹ÊÕÏתÒÆȺ¼¯ÊÇÁ½Ì¨·þÎñÆ÷£¬Ò»Ì¨×ö»î¶¯µÄ·þÎñÆ÷£¬Áíһ̨×ö±¸Ó÷þÎñÆ÷£¬Õâ¾ÍÊÇAPģʽµÄCluster¡£ÁíÍâÒ»¸öģʽ¾ÍÊÇAAģʽ£¬Ò²¾ÍÊÇÁ½Ì¨·þÎñÆ÷¶¼ÊÇÔËÐÐSQL ServerʵÀý¡£
SQL Server²»ÏñOracleÒ»ÑùÓÐRAC£¬ËùÒÔ²»¿ÉÄÜ˵Á½Ì¨·þÎñÆ÷ͬʱÔËÐÐͬһ¸öʵÀý£¬Ïë ......
SQLº¯ÊýÖ®ËÄÉáÎåÈ루ת×Ôhttp://ln1058.javaeye.com/blog/191502£©
ÎÊÌâ1£º
SELECT CAST('123.456' as decimal) ½«»áµÃµ½ 123£¨Ð¡ÊýµãºóÃæµÄ½«»á±»Ê¡ÂÔµô£©¡£
Èç¹ûÏ£ÍûµÃµ½Ð¡ÊýµãºóÃæµÄÁ½Î»¡£
ÔòÐèÒª°ÑÉÏÃæµÄ¸ÄΪ
SELECT CAST('123.456' as decimal(38, 2)) ===>123.46
×Ô¶¯ËÄÉáÎåÈëÁË£ ......
Ò»¡¢Ê¹ÓòÎÊý»¯ÊäÈë¡£´æ´¢¹ý³ÌÀᄀÁ¿±ÜÃâÓï¾äÆ´½Ó¡£
¶þ¡¢¶ÔÓÚһЩÊý¾Ý¿â£¬±ØÐëÉèÖÃȨÏÞ£¬ÉõÖÁÉèÖõ½×ֶΡ£
Èý¡¢Ê¼ÖÕͨ¹ý²âÊÔÀàÐÍ¡¢³¤¶È¡¢¸ñʽºÍ·¶Î§À´ÑéÖ¤Óû§ÊäÈë¡£
ËÄ¡¢¹ýÂËÃô¸Ð×Ö·û¡£
Function ReplaceStr(Str)
Str=Trim(Str)
Str=Replace(Str,"'","'")
Str=Replace(Str,";",";")
Str=Rep ......
--> Title : SQL Server²é詢¿ÉÓôÅÅÌ¿Õ¼ä
--> Author : wufeng4552
--> Date : 2009-10-30 09:59:09
Ç°ÑÔ
Èç¹ûÄãµÄ×éÖ¯ÓµÓеijÌÐòÒªÇóÒ»¸öºÜ´óÁ¿µÄ´ÅÅÌ¿Õ¼ä»òÕß´ó±ÈÀýµÄÌض¨´ÅÅÌ£¬ÄÇôȷ±£ÔÚ³ÌÐò¿ªÊ¼»òÕ߹ؼüµãʱȷÈÏ´ÅÅÌÇý¶¯Æ÷¾ßÓÐ×ã¹»µÄ´æ´¢¡£Ò»´Î¿ìËÙ¼ì²é¾Í¿ÉÒÔ½ÚÔ¼´óÁ¿µÄʱ¼ä£¬¼õ ......
Ò».×¢ÊÍ
-- µ¥ÐÐ×¢ÊÍ£¬´ÓÕâµ½±¾ÐнáÊøΪעÊÍsql Óï·¨£¬ÀàËÆC++£¬c#ÖÐ//
/* ¡ */ ¶àÐÐ×¢ÊÍ£¬ÀàËÆC++£¬C#ÖÐ/* ¡ */
¶þ.±äÁ¿£¨int£¬ smallint£¬ tinyint£¬ decimal£¬float£¬real£¬ money £¬smallmoneysql Óï·¨£¬ text £¬image£¬ char£¬ varchar¡£¡£¡£¡£¡£¡££©
Óï·¨£º
DECLARE
&nb ......