如何为相关项目设计表格

编程入门 行业动态 更新时间:2024-10-26 22:19:20
本文介绍了如何为相关项目设计表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要将相关项添加到现有数据库中。我有这样的结构:

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

更多推荐

如何为相关项目设计表格

本文发布于:2023-07-26 09:33:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1215521.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:何为   表格   项目

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!