连关系都不知道吗?买本数据库书看看吧!
declare @a table(a int,b int)
declare @b table(a int,b int)
insert @a values(1,1)
insert @a values(2,2)
insert @b values(1,1)
insert @b values(3,3)--左:
select * from @a Aa left join @b Bb on Aa.a=Bb.a
--右:
select * from @a Aa right join @b Bb on Aa.a=Bb.a
--内
select * from @a Aa join @b Bb on Aa.a=Bb.a
--外
select * from @a Aa full join @b Bb on Aa.a=Bb.a
--完全
select * from @a,@b

解决方案 »

  1.   

    是为了约束如:Create database cat
    go
    use cat
    go
    CREATE TABLE s(s# int not null primary key,s_name varchar(8) not null)
    go
    CREATE TABLE c (c# int not null primary key,c_name varchar(8) not null)
    go
    CREATE TABLE cs(c# int not null,s# int not null,cj tinyint not null default(0),
    primary key (c#,s#),foreign key(s#) references s(s#),foreign key(c#) references c(c#))
    go你在没有向s表或c表插入数据的时候,向cs表插入会报错的!
      

  2.   

    多谢各位!谁能再解释一下,在建立Relationship的时候,底下的几个复选框都什么意思啊?
    Check existing data on creation
    Enforce relationship for replication
    Enforce relationship for INSERTs and Update
      Cascade Update Related Fields
      Cascade Delete Related Records