×î½üÓÐÅóÓÑÓöµ½Ê¡ÊеÄÎÊÌ⣬ÏëÏë×Ô¼º½ñºóÒ²ÓпÉÄÜ»áÓöµ½£¬ËùÒÔ¾Í×Ô¼ºÔÚÍøÉÏдд£¬ËÑËÑ£¬Ö÷ÒªÊǶÔ×Ô¼º½ñºóÓвο¼
--´´½¨Êý¾Ý¿â
create database NationalAll
Go
--ʹÓÃNationalAllÊý¾Ý¿â
use NationalAll
Go
--´´½¨Ê¡¼¶±í
Create Table Province
(
ProID int primary key not null,
ProName nvarchar(50) not null
)
Go
--Öйú34¸öÊ¡¼¶ÐÐÕþµ¥Î» 23¸öÊ¡ 5¸ö×ÔÖÎÇø 4¸öֱϽÊÐ 2ÌرðÐÐÕþÇø
insert into Province values(1,'±±¾©ÊÐ')
insert into Province values(2,'Ìì½òÊÐ')
insert into Province values(3,'ÉϺ£ÊÐ')
insert into Province values(4,'ÖØÇìÊÐ')
insert into Province values(5,'ºÓ±±Ê¡')
insert into Province values(6,'ɽÎ÷Ê¡')
insert into Province values(7,'̨ÍåÊ¡')
insert into Province values(8,'ÁÉÄþÊ¡')
insert into Province values(9,'¼ªÁÖÊ¡')
insert into Province values(10,'ºÚÁú½Ê¡')
insert into Province values(11,'½ËÕÊ¡')
insert into Province values(12,'Õã½Ê¡')
insert into Province values(13,'°²»ÕÊ¡')
insert into Province values(14,'¸£½¨Ê¡')
insert into Province values(15,'½Î÷Ê¡')
insert into Province values(16,'ɽ¶«Ê¡')
insert into Province values(17,'ºÓÄÏÊ¡')
insert into Province values(18,'ºþ±±Ê¡')
insert into Province values(19,'ºþÄÏÊ¡')
insert into Province values(20,'¹ã¶«Ê¡')
insert into Province values(21,'¸ÊËàÊ¡')
insert into Province values(22,'ËÄ´¨Ê¡')
insert into Province values(23,'¹óÖÝÊ¡')
insert into Province values(24,'º£ÄÏÊ¡')
insert into Province values(25,'ÔÆÄÏÊ¡')
insert into Province values(26,'Çຣʡ')
insert into Province values(27,'ÉÂÎ÷Ê¡')
insert into Province values(28,'¹ãÎ÷׳×å×ÔÖÎÇø')
insert into Province values(29,'Î÷²Ø×ÔÖÎÇø')
insert into Province values(30,'ÄþÏÄ»Ø×å×ÔÖÎÇø')
insert into Province values(31,'н®Î¬Îá¶û×ÔÖÎÇø')
insert into Province values(32,'ÄÚÃɹÅ×ÔÖÎÇø')
insert into Province values(33,'°ÄÃÅÌرðÐÐÕþÇø')
insert into Province values(34,'Ïã¸ÛÌرðÐÐÕþÇø')
Go
--´´½¨Ê춱í
Create Table City
(
CityID int not null,
CityName nvarchar(50) primary key not null,
ProID int
)
go
--²åÈë¸÷¸öÊ¡µÄ³ÇÊ
×î½ü¹«Ë¾ÔÚÕÐÈË£¬Í¬ÊÂÎÊÁ˼¸¸ö×ÔÈÏΪÊý¾Ý¿â¿ÉÒÔµÄӦƸÕß¹ØÓÚ¿âÁ¬½ÓµÄÎÊÌ⣬»Ø´ð²»¾¡ÀíÏë¡«
ÏÖÔÚÔÚÕâдд¹ØÓÚËüÃǵÄ×÷ÓÃ
¼ÙÉèÓÐÈçÏÂ±í£º
Ò»¸öΪͶƱÖ÷±í£¬Ò»¸öΪͶƱÕßÐÅÏ¢±í¡«¼Ç¼ͶƱÈËIP¼°¶ÔӦͶƱÀàÐÍ£¬×óÓÒÁ¬½Óʵ¼Ê˵ÊÇÎÒÃÇÁªºÏ²éѯµÄ½á¹ûÒÔÄĸö±íΪ׼¡«
1£ºÈçÓÒ½ÓÁ¬ right join »ò right outer join£º
ÎÒÃÇÒÔÓÒ±ß ......