--try
alter table comment 
add constraint fk_UserId FOREIGN KEY (`Userid`) REFERENCES `users` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE,
add constraint fk_NewsID FOREIGN KEY (`NewsID`) REFERENCES `news` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE  

解决方案 »

  1.   

    --錯了, 改改
    alter table comment 
    add constraint fk_UserId FOREIGN KEY (Userid) REFERENCES users(Id) ON DELETE CASCADE ON UPDATE CASCADE,
    constraint fk_NewsID FOREIGN KEY (NewsID) REFERENCES news (ID) ON DELETE CASCADE ON UPDATE CASCADE
      

  2.   

    create table A(AID int not null primary key, name varchar(10))
    gocreate table B(BID int not null primary key, name varchar(10))
    gocreate table C(CID int, AID int, BID int)
    goalter table C
    add constraint fk_AID foreign key(AID) references A(AID) on delete cascade on update cascade,
    constraint fk_BID foreign key(BID) references B(BID) on delete cascade on update cascade
    godrop table C
    drop table A, B
    go