By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,961 Members | 1,320 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,961 IT Pros & Developers. It's quick & easy.

How to check for unique value depending on another column value...

P: 21
I am having table which contains 2 columns (qid,round) and both columns can have repeated values but one constraint is for each 'round' the 'qid' values should not be repeated.

qid:1,2,3,1,2---should be unique for each round...

can any body suggest me a query for this..??
Apr 19 '10 #1
Share this Question
Share on Google+
7 Replies

Expert 100+
P: 700
So you need unique constraint on both columns (qid,round)
Apr 19 '10 #2

P: 21
ya..depending on each other...
Apr 19 '10 #3

Expert 100+
P: 700
What do you mean? My english is not as good i'm afraid :).
Apr 19 '10 #4

P: 21
i mean the same as u said unique constraint on both columns...i think you understood what was my problem....
Apr 19 '10 #5

Expert 100+
P: 700
Yes I understood (i think i did) and that's why i suggested to create one uniqe constraint on both column because you want the pair of values (round,qid) to be unique don't you?
Apr 19 '10 #6

P: 21
ya how to get it...and wat cud be the query...
Apr 19 '10 #7

P: 21
Hi rski, i got solution of course it was easy...just set a unique constraint on two columns by UNIQUE(column1,column2)...I think it is basic concept but i am very new to postgre sql....Thank you....
Apr 23 '10 #8

Post your reply

Sign in to post your reply or Sign up for a free account.