在多对多关系中从查找表分配值
我有下表:
Persons(
PersonID,
FirstName,
LastNAme)
Person_Categories(
CategoryID,
CategoryName)
Persons_PersonCategories(
PersonID,
CategoryID)
一个人可以有多个类别,很多人可以属于一个类别。 我希望能够从下拉菜单(Person_Categories)中为人员分配类别。我编写了以下查询,如果已经为人员分配了类别,则该查询会显示数据。
SELECT Persons_PersonCategories.PrsCatID, PrsCategory
FROM Person_Categories
INNER JOIN Persons_PersonCategories
ON Persons_PersonCategories.PrsCatID = Person_Categories.PrsCatID;
我的问题:我需要什么sql语句将Person_Categories表中的类别分配给Persons?
非常感谢,赞
I have the following tables:
Persons(
PersonID,
FirstName,
LastNAme)
Person_Categories(
CategoryID,
CategoryName)
Persons_PersonCategories(
PersonID,
CategoryID)
One person can have more than one category and many people can belong to one category.
I want to be able to assign categories to persons from a drop down menu (Person_Categories). I've written the following query which displays data if there are already categories assigned to persons.
SELECT Persons_PersonCategories.PrsCatID, PrsCategory
FROM Person_Categories
INNER JOIN Persons_PersonCategories
ON Persons_PersonCategories.PrsCatID = Person_Categories.PrsCatID;
My question: What sql statement do I need to assign categories from the Person_Categories table to Persons?
Many thanks, zan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当用户从菜单列表中选择类别时,您可以将其分配给人员:
其中 <人员 ID> 和 <类别 ID> 分别代表人员您要分配的类别以及用户选择的类别。
要从给定人员中删除类别,您可以使用:
其中 <人员 ID> 和 <类别 ID> 分别代表要从中删除类别的人员和用户正在删除的类别。
希望这有帮助。
When the user selects a category from the menu list, you can assign it to a person with:
where <person ID> and <category ID> respectively represent the person you are assigning to and the category the user has choosen.
To remove a category from a given person, you can use:
where <person ID> and <category ID> respectively represent the person you are removing categories from and the category the user is removing.
Hope this helps.