0

I must create a table for handling student data which has two columns department code and register number,. For Eg. dept 101 has 30 students with register numbers (1-30) And dept 102 has 30 different students with same register numbers (1-30) . for instance.,The student with regno:3 who belongs to dept:101 and another student with regno:3 but in the dept:102 are in same table.,There can be same regno's but different dept code is there a way to relate my two columns.. I have added another image for more clarifications Table Structure with data My problem is how can i have unique set register numbers for each deparment in the same column to avoid duplication. The Values of reg_no with same Department Code must have a unique set,.. and another set of regno with a different dept_code must have another or individual set of unique set of numbers Can i Have Multiple unique sets in a single Column..?? The Table sample image

Is there any solution or should i use another table for each dept_code

Tried on Googling didn't Get a result yet . Thanks in Advance

Isaac Bennetch
  • 11,830
  • 2
  • 32
  • 43
Shangeeth Sivan
  • 2,150
  • 1
  • 20
  • 20
  • 1
    Edit your question and provide sample data. It is not clear what you are asking for. – Gordon Linoff Jan 02 '16 at 20:22
  • Yep, need more details. You most certainly do not need to create tables per dept_code. You just should explain in more detail what is You problem? What You want to achieve? What is reg_no? What is dept_code? Is set of dept_code assigned to given reg_no stored in database somwhere? – T.Z. Jan 03 '16 at 12:42

1 Answers1

1

try this

UNIQUE KEY 'thekey' ('dept','regno');

more about the background is found at this StackOverflow post

Community
  • 1
  • 1
RAJESH KUMAR ARUMUGAM
  • 1,560
  • 21
  • 35