Mysql Help Needed -


i have table named group info. has 3 fields namely id,user_id, , group_id. question how assign unique users group i-e same user may not repeated in same group. table structure group info follows;

id         int(11)  auto increment,primary key not null,  user_id    int(11)  not null,  group_id   int(11)  not null 

i have made user_id unique.but there 2 groups(2 group_id(1 , 2)).selecting users groupb gives error duplicate entry. user_id = 1,2,3,4,5,6,7,8; group_id= 1,2;

kindly me how solve this.iam not in english apologies language.

alter table `tbl_name` add unique ( `col1` , `col2` ); 

change col1 user_id , col2 group_id , tbl_name table name.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -