How to write this query

Hi all Plz se this below

UsersID!!!!!!! name !!!!!!!Match_ID!!!!!!!!!!!! Matches

===================================

1!!!!!!!!!!!!USER1!!!!!!!!21 !!!!!!!!! IND vs S.A

2!!!!!!!!!!!!USER2!!!!!!!!301 !!!!!!!! AUS vs S.A

.:

..:

=======================================================

My Question is :

1>User1 must be able to bet matches for only one time ie (User1 can bet Match_ID 21 and 301 but only for one time )

2> similarly for User2

3> and so on

4> What i am doing is I am giving Primary key For the Match_ID so

for only User1 it is satisfying the condition but for User2 it is showing this error:-> java.sql.SQLException: Duplicate entry '301' for key 1

So how do we proceed plz give me hint

Thanks

Message was edited by:

saamer

[863 byte] By [saamera] at [2007-11-27 2:06:08]
# 1
You have to set an unique constraint on the combination UserID+MatchID, not only an (overkilled) PK on MatchID.I recommended you to read some SQL tuts however, since this has nothing to do with JDBC. http://www.google.com/search?q=sql+tutorial
BalusCa at 2007-7-12 1:52:54 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
stop answering questions of this guy. He'll never give dukes !!See his profile...
java_2006a at 2007-7-12 1:52:54 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
I don't care about the dukes.
BalusCa at 2007-7-12 1:52:54 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4
>I don't care about the dukes.Right, but he'll not even thank you
java_2006a at 2007-7-12 1:52:54 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5
> >I don't care about the dukes.> Right, but he'll not even thank youMost of them don't.
DrClapa at 2007-7-12 1:52:54 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 6
Indeed.So, what are dukes anyway?Thanks for the answer :).
cubejdeva at 2007-7-12 1:52:54 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...