Question

I have a table of users, students and teachers. For example I want to create a new student and assign him a user account from the list. This works for me, but it is possible to assign the same user account to more students. How to fix this? Thank you.

Était-ce utile?

La solution

you should add unique index in students table, user_id field, this not allow to repeat, the same user_id, in students table.

http://dev.mysql.com/doc/refman/5.0/es/create-index.html.

You should use, "UNIQUE".

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top