ÎÊÌâÃèÊö£º
1¡¢¼ÙÉèÓбí
t1±í£¬°üº¬ËÄÁÐ
s1 a b c
1 a a a
2 b b b
.........
t2±í£¬°üº¬2ÁÐ
s2 ff
1 77
2 88
............
ÈçºÎÉú³ÉÕâÑùµÄºÏ²¢ÊÓͼ
s1 a b c ff
1 a a a
2 b b b
1 77
2 88
ÎÊÌâ2£º
¼ÙÉèÄÜÉú³ÉÉÏÊöÊÓͼ£¬ÏÖÔÚÒªÇëÇ󣬱êʶ³öÊý¾ÝÊÇÀ´Ô´
¼ÙÉèÀ´×Ôt1°×µÄÊý¾Ý±êʾ·ûΪxx,À´×Ôt2±íµÄÊý¾Ý±êʶΪyy
ÄÇô£¬ÈçºÎÉú³ÉÕâÑùµÄÊÓͼ£º
s1 a b c ff mm(ÐÂÁÐ)
1 a a a xx
2 b b b xx
1 77 yy
2 88 yy
ÒªÇóÊDz»ÄÜÐÞ¸Ät1,t2µÄ±í½á¹¹£¡£¡£¡£¡
·Ö²»¹»Ëµ£¬Áí¿ªÌù¼Ó
ʹÓÃunionºÍnullÔÚÎÊÌâ1ÖÐÊÔ¹ý£¬ÌáʾÁÐÖµ²»Æ¥Å䣡£¡
ÎÊÌâ2£º
select s1, a, b, c,null ff,'XX' mm from t1
union all
select null s1, null a, null b,null c, ff,'YY' mm from t2;
¼¼ÊõÉϵ¹ÊDz»ÄÑÌ⣬ֻÊÇÕâ¸öÐèÇóÓеãÆæ¹Ö..
Â¥ÉϻشðÒѾ²î²»¶àÁË¡£union allÏÂÃæµÄÁбðÃû¾Í²»ÓüÓÁË
select s1,a,b,c,null ff,'XX' mm from t1
union all
select s1,null,null,null,ff,'YY' from t2
´´½¨ÊÓͼ
create view VIEWNAME
as
select s1,a,b,c,null ff,'XX' mm from t1
union all
select s1,null,null,null,ff,'YY' from t2
¶¥Æð
ѧϰUnion AllÓï·¨ÁË¡£
ÎÒµÄÎÊÌâ1£¬¾ÍÊÇÓÃunion º
ÎÒ¶ÔSQL SERVERºÍACCESS±È½ÏÊ죬ËùÒÔÊý¾Ý¿âµÄͨÓûù´¡¶«Î÷¿ÉÒÔ˵¶¼ÕÆÎյIJ¶àÁË£¬ÎÒÏÖÔÚÏëÒªµÄ¾ÍÊÇÒÔÉÏÁ½Êý¾Ý¿âµÄ¶ÀÌØÖ®´¦µÄ½éÉܺÍÓ¦ÓýéÉÜ¡£
ÁíÍâÊé×îºÃ¶ÔÓ¦×îа汾 oracleÊÇ11g°É 10µÄÒ²ÐУ»mysqlÊÇ5.1°É
л ......
ÏÖÔÚÎÒ±¾µØûÓа²×°oracle, µ«plsqldevÐèÒªsqlplus.exeµÈ£¬ÇëÎÊoracle10gÔÚwindowsÐèÒª
ÄÄЩexeÎļþ£¬ÄÄλ´ó¸çÄÜ˳±ãÌṩһÏÂQQ£º190565390
×°oracleµÄʱºò¿ÉÒÔÑ¡ÔñÖ»×°¿Í»§¶ËµÄ
×îÆðÂëҪװoracle£¬ÄãÖ»Ðè×°¿ ......