本文介绍了如何为相关项目设计表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将相关项添加到现有数据库中。我有这样的结构:
ID int ,PK Iname nvarchar ( 80 ) ...可以我添加anoter列并存储相关的项ID或实现相关项的最佳方法是什么?有时我需要添加多个相关项目。请帮助
解决方案您需要创建另一个这样的表 CREATE TABLE dbo.RItems ( Id1 int 不 null , Id2 int 不 null )
并通过执行此查询简化所有相关项目
SELECT Id2 FROM RItems WHERE Id1 = @ ID
I need to add related items to an existing database. I have structure like this:
ID int, PK Iname nvarchar(80) ...Can i add anoter column and store related item ID or what is the best way to implement related items? Sometimes i need to add more than one related item. Please help
解决方案 You need to create another table like this CREATE TABLE dbo.RItems ( Id1 int not null, Id2 int not null )and get all related items simple by executing this query
SELECT Id2 FROM RItems WHERE Id1 = @ID更多推荐
如何为相关项目设计表格
发布评论