Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Inserting multiple values in a single column

Author  Topic 

pooja28
Starting Member

6 Posts

Posted - 2011-03-17 : 09:29:32
hi to all, I created following table

create table book(id integer, author varchar(20))

In this, each book may have 1 or more authors.

My question is that, how can insert more value to author column like as follows.


id author
1 pooja merry james
2 robert stephen





Thanks & Regards,
Pooja

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2011-03-17 : 09:34:11
don't do that. you should have 3 tables. Book, Author, and BookAuthor.

1 row in Book for each book, 1 row in Author for each author. which authors authored which books is stored in BookAuthor.

this is implemented in the sample database pubs btw. although there I think instead of Book they call it Title.


elsasoft.org
Go to Top of Page

pooja28
Starting Member

6 Posts

Posted - 2011-03-17 : 09:38:40
@jezemine, can u explain with an example.

Thanks & Regards,
Pooja
Go to Top of Page

dbleh
Starting Member

3 Posts

Posted - 2011-03-17 : 12:19:49
Yes, please show an example. I am stuck with same thing with a one to many relationship. I need to know how to update my tables when VehicleID has many options. I have Vehicles Table Options Table and VehicleOptions Table.

Thank You
Go to Top of Page
   

- Advertisement -