Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old November 13th, 2005, 09:59 AM
roach04
Guest
 
Posts: n/a
Default Help With Sub Query

Hi Folks,

Using Access 2003.

ArtistsTable
ID
Artist

AlbumsTable
AlbumName
LookUpToArtistsTable

My problem -- how can I write a query that will give me all the album
names for a given artist in one record?

I know if I do "SELECT ArtistsTable.Artist, AlbumsTable.AlbumName From
ArtistsTable LEFT JOIN AlbumsTable ON ArtistsTable.ID =
AlbumsTable.LookUpToArtistsTable" I can get a recordset that looks
like this:

"Beatles", "Revolver"
"Beatles", "Rubber Soul"
"Beatles", "Let It Be"

But what I'm looking for is:

"Beatles", "Revolver, Rubber Soul, Let It Be"

Any help appreciated!

Thanks,

Murray
  #2  
Old November 13th, 2005, 09:59 AM
Jeff Smith
Guest
 
Posts: n/a
Default Re: Help With Sub Query

try
http://www.mvps.org/access/modules/mdl0004.htm


"roach04" <murray.roach@gmail.com> wrote in message
news:6ae7960c.0504151944.375201ae@posting.google.c om...[color=blue]
> Hi Folks,
>
> Using Access 2003.
>
> ArtistsTable
> ID
> Artist
>
> AlbumsTable
> AlbumName
> LookUpToArtistsTable
>
> My problem -- how can I write a query that will give me all the album
> names for a given artist in one record?
>
> I know if I do "SELECT ArtistsTable.Artist, AlbumsTable.AlbumName From
> ArtistsTable LEFT JOIN AlbumsTable ON ArtistsTable.ID =
> AlbumsTable.LookUpToArtistsTable" I can get a recordset that looks
> like this:
>
> "Beatles", "Revolver"
> "Beatles", "Rubber Soul"
> "Beatles", "Let It Be"
>
> But what I'm looking for is:
>
> "Beatles", "Revolver, Rubber Soul, Let It Be"
>
> Any help appreciated!
>
> Thanks,
>
> Murray[/color]


  #3  
Old November 13th, 2005, 09:59 AM
Justin Hoffman
Guest
 
Posts: n/a
Default Re: Help With Sub Query


"roach04" <murray.roach@gmail.com> wrote in message
news:6ae7960c.0504151944.375201ae@posting.google.c om...[color=blue]
> Hi Folks,
>
> Using Access 2003.
>
> ArtistsTable
> ID
> Artist
>
> AlbumsTable
> AlbumName
> LookUpToArtistsTable
>
> My problem -- how can I write a query that will give me all the album
> names for a given artist in one record?
>
> I know if I do "SELECT ArtistsTable.Artist, AlbumsTable.AlbumName From
> ArtistsTable LEFT JOIN AlbumsTable ON ArtistsTable.ID =
> AlbumsTable.LookUpToArtistsTable" I can get a recordset that looks
> like this:
>
> "Beatles", "Revolver"
> "Beatles", "Rubber Soul"
> "Beatles", "Let It Be"
>
> But what I'm looking for is:
>
> "Beatles", "Revolver, Rubber Soul, Let It Be"
>
> Any help appreciated!
>
> Thanks,
>
> Murray[/color]


If you really need a query, you could use a crosstab query (if you don't
mind the column names):

TRANSFORM First(AlbumName) AS Album
SELECT Artist FROM
(SELECT * FROM AlbumsTable INNER JOIN ArtistsTable
ON AlbumsTable.LookUpToArtistsTable=ArtistsTable.ID) AS X
WHERE Artist="Beatles"
GROUP BY Artist PIVOT AlbumName

There may be another non-query solution, depending on your ultimate goal.


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles