I made a table named staff_info containing 4 column name,day,duty_start,duty_finish. This table still have no parimary key. Now assume that there are 4 staff and they do their work in each day of the week.That means in each day there work 4 staff and 1 staff work in 7 days. Ultimately i can't either make name or day column as my primary key.But combination of two column value is unique.Is there any way that i can make the combination of these two column as any kind of primary key? I think i made myself clear.
Jump to Post
I'm not sure to understand what you need but you could add a primary key with both fields:
alter table staff_info add primary key('fieldA','fieldB');
just make sure these are less than 1000 bytes and not nullable; if the same value combination is submitted the query will …
Jump to Post
cereal already told you the solution
alter table staff_info add primary key('name','day');
or you can open table structure in phpmyadmin, and check on both column, then click on primary key at the boottom of table structure.
So after doing this, table will not expect same day for any person.
All 6 Replies
We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.