Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Combining the contain of some records
Message
From
30/07/2003 10:55:48
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
30/07/2003 10:00:06
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00814905
Message ID:
00814935
Views:
8
This message has been marked as the solution to the initial question of the thread.
>dear all,
>
>I do need some help..
> I'm working on a library project. There are 3 related tables : TAuthor, Tbook and TBookAuthor. TAuthor is a table for author's information, TBook is a table for book's information, and TBookAuthor is a table to store information (cBookID & cAuthorID) that relate TAuthor and TBook, because a book may have more than one author.
> The problem is i want to browse the information of the book in a grid, where all of the author name of the book will be appear in a single column. I'm going to use it to display the result on searching process too.
> I've thought about add a new table that contain 2 fields: cBookID and cAuthorName, where cAuthorName is filled by all of the authorname in a book that will be seperated only by a comma. But i'm not sure that's a good idea because i can't determine the best length of the field, it could be too large or too small.
> What should i do? Any comment will help me... thank's before...
>
>
>Love,
>Gloria
>
>
>"a new day means a new hope"

Do not create a new table. Maintaining it might be harder than it sounds.
Instead create a cursor when you need and show that in grid. ie:
select a.AuthorName, b.Book, b.bookID ;
 from TAuthor a ;
 inner join TAuthorBook c on a.authorID = c.authorID ;
 inner join TBook b on b.bookID = c.bookID ;
 into cursor crsAll nofilter

create cursor crsGrid (Author m, Book c(fsize('Book','Tbook'))
luBookID = 0
scan
  if bookID # luBookID
     luBookID = bookID
     lcAuthors = ''
     scan while bookID = luBookID
        lcAuthors = lcAuthors + iif(empty(lcAuthors),'',',')+AuthorName
     endscan
     insert into crsAll (Author, Book) values ;
        (lcAuthors, crsAll.Book)
     skip -1
endscan 

thisform.myGrid.RecordSource = 'crsAll' 
Assuming you already created a grid with 2 columns where you added an editbox control to 1st column :
CurrentControl= 'Edit1'
Sparse = .f.
and sized column, rowheight as appropriate.

Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform