Fritz Theiss
3/19/2007 9:39:00 PM
Thanks again.
However I have created a third table called ActorDVDInfo with a primar key
beside of the other two fields ActorId and DVDInfoId, which "point" to my
tables in question.
But when creating my Join-Clause it still fails. Can you please let me know
the appropriate T-SQL?
--
Fritz Theiss
"Sylvain Lafontaine" wrote:
> ADP: Active Data Project, the other method for accessing a SQL-Server from
> Access; the first one being the ODBC linked tables/sql passthrough queries
> and the third one using independant connections/recordsets with either DAO
> or ADO.
>
> --
> Sylvain Lafontaine, ing.
> MVP - Technologies Virtual-PC
> E-mail: sylvain aei ca (fill the blanks, no spam please)
>
>
> "Fritz" <Fritz@discussions.microsoft.com> wrote in message
> news:66DE5477-7345-4EBC-BE90-867D0FF0F93A@microsoft.com...
> > Thanks, Sylvain - this sounds good.
> >
> > Indeed I am using Access :-(. So I am wondering what ADP means...
> >
> > Thanks again, Fritz
> > --
> > Fritz Theiss
> >
> >
> >
> >
> > "Sylvain Lafontaine" wrote:
> >
> >> You can have multiple key in a single relationship:
> >>
> >> ... ON (Actors.ActorId = DVDInfo.ActorId1 or Actors.ActorId =
> >> DVDInfo.ActorId2 or ...)
> >>
> >> Using an alias will help you writing (and understanding) this stuff:
> >>
> >> FROM Actors as A INNER JOIN DVDInfo D ON (A.ActorId = D.ActorId1 or
> >> A.ActorId = D.ActorId2 or ...)
> >>
> >> In your case, the best solution would be to redesign the layout of your
> >> tables. You are in a situation where one DVD might have one or more
> >> Actor
> >> and one Actor be part of more than one DVD, this is called a N:N
> >> relationship and is done by creating/using a third table to maintain the
> >> relationship between the first two tables. This table will contains one
> >> DVDId and one ActorID by row. You can use these two fields as the
> >> primary
> >> key of your table or if you are using things like Access as the
> >> interface,
> >> add a third field with an identity value to act as an independant primary
> >> key. (This third field is not mandatory but will save you many problems
> >> with things like Access ADP.)
> >>
> >> Whether or not the fact that you will be using the two ID fields as the
> >> primary key, probably that it won't be a bad idea to add a second unique
> >> index with these two fields reversed in order to increase retrieval
> >> performance. If you want to have a clustered index, the best choice
> >> would
> >> be to use any of these indexes that will begin with the DVDId field
> >> because
> >> you are more likely to add a new DVD and possibly reuse one or more
> >> existing
> >> actor than to create an actor and add his name to a collection of already
> >> created DVD records.
> >>
> >> --
> >> Sylvain Lafontaine, ing.
> >> MVP - Technologies Virtual-PC
> >> E-mail: sylvain aei ca (fill the blanks, no spam please)
> >>
> >>
> >> "Fritz" <Fritz@discussions.microsoft.com> wrote in message
> >> news:84EF72F8-81D4-4A18-9970-EDECABCC2DFD@microsoft.com...
> >> > hi,
> >> >
> >> > i got 2 tables called dvdinfo and actor. inside dvdinfo one can find
> >> > i.e.
> >> > titel, director, actorid1, actorid2, actorid3...
> >> >
> >> > inside actor i have added actorid and actor. actorid is thought as 1:n
> >> > relationship to dvdinfo.actorid<x>.
> >> >
> >> > i know want to see an output as following:
> >> >
> >> > select titel, director, actor1, actor2, actor3 from dvdinfo, actor,
> >> > which
> >> > could end as outut i.e. "ocean's eleven, steven soderbergh, george
> >> > clooney,
> >> > brad pitt, matt damon".
> >> >
> >> > my select-clause is obviously wrong:
> >> >
> >> > SELECT DVDInfo.Titel, DVDInfo.Director, Actors.Actor as Actor1
> >> > FROM Actors INNER JOIN DVDInfo ON Actors.ActorId = DVDInfo.ActorId1,
> >> > Actors.Actor as Actor2 FROM Actors INNER JOIN DVDInfo ON Actors.ActorId
> >> > =
> >> > DVDInfo.ActorId2, Actors.Actor as Actor3 FROM Actors INNER JOIN DVDInfo
> >> > ON
> >> > Actors.ActorId = DVDInfo.ActorId3;
> >> >
> >> > what would be the right one? or do i have to change the layout of my
> >> > tables?
> >> >
> >> > thanks in advance, fritz
> >> > --
> >> > Fritz Theiss
> >>
> >>
> >>
>
>
>