Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
cool
Starting Member
2 Posts |
Posted - 2007-08-07 : 15:00:09
|
| hi am new to sql...i need to write a query ..it is like two teams can play more than 1 game but on different dates..so if i create the table like thisCreate Table Games( TeamName1 char(30), 2 numGoals1 int, 3 TeamName2 char(30), 4 numGoals2 int, 5 play_date char(10), 6 primary key(TeamName1,TeamName2,play_date), 7 Check(TeamName1!=TeamName2) 8 );this violates the constraint if i give the two teams on the same date..how to give the condition such that it checks for the violation of condition if the team names are interchanged.. for egif i give the values asInsert Into Games values('chelsea',1,'arsenal',2,'17-1-2000');andInsert Into Games values('arsenal',1,'chelsea',2,'17-1-2000');the above should violate the constraint ..how to do it |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2007-08-07 : 15:39:08
|
| You could add a check constraint to force them to enter the the team names in order by name. Then you would have only one possible way to enter the data.check ( TeamName1 < TeamName2 )CODO ERGO SUM |
 |
|
|
cool
Starting Member
2 Posts |
Posted - 2007-08-07 : 17:01:37
|
| thank u |
 |
|
|
|
|
|
|
|