如何在单列中添加多个值

时间:2022-05-21 20:22:44

I am designing a SQL table structure as:

我正在设计一个SQL表结构:

 CREATE TABLE InCollection (
       author NVARCHAR(200) DEFAULT NULL,
       title TEXT,
       year INT DEFAULT '0',
       booktitle TEXT )

Now column 'author' may have a single value or multiple tags as

现在列'author'可能只有一个值或多个标签

<author></author>

or

<author></author><author></author><author></author>

So how to define this column in table structure, so I would be able to insert single value or multiple value in 'author' when found multiple values.

那么如何在表结构中定义这个列,所以当找到多个值时,我可以在'author'中插入单值或多值。

1 个解决方案

#1


You can add multiple values to a single column by appending the values with some symbol like ",". While getting the values from user interface combine or join them with "," make the values as a single string and then pass the value to the column.

您可以通过使用“,”等符号附加值来向单个列添加多个值。从用户界面获取值并将它们与“,”组合在一起时,将值作为单个字符串,然后将值传递给列。

#1


You can add multiple values to a single column by appending the values with some symbol like ",". While getting the values from user interface combine or join them with "," make the values as a single string and then pass the value to the column.

您可以通过使用“,”等符号附加值来向单个列添加多个值。从用户界面获取值并将它们与“,”组合在一起时,将值作为单个字符串,然后将值传递给列。