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.

有帮助吗?

解决方案

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".

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top