Hi,
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.
shihab2555
0
Light Poster
Recommended Answers
Jump to PostI'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 Postcereal 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.
But …
All 6 Replies
cereal
1,524
Nearly a Senior Poster
Featured Poster
shihab2555
0
Light Poster
mwatson81
0
Newbie Poster
shihab2555
0
Light Poster
urtrivedi
276
Nearly a Posting Virtuoso
vgaldikas
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.