vinyl-junkie
06-01-2003, 11:43 PM
Hi all,
I'm trying to do a select within a select and having problems with it. First of all, let me explain the table structure I'm referencing.
tblArists can have 1 to many tblAlbums entries
tblAlbums can have 1 to many tblTracks entries
tblArtists and tblAlbums are joined by ArtistID
tblAlbums and tblTracks are joined by AlbumID
What I am trying to do is select artists who appear in the tblArtists.Artist or tblTracks.ArtistFullName fields in the database, then list only Artist, Album, and MediaType in a table. In order to do that, I need to do a select within a select. Here's the error I'm getting in my code:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'tblAlbums.MediaType a (SELECT tblAlbums.Title, tblAlbums.TitleSort, tblAlbums.MediaType, tblAlbums.AlbumID, tblArtists.The, tblArtists.Artist, tblArtists.ArtistID, tblArtists.SortName FROM tblArtists INNER JOIN tblAlbums ON a.tblArtists.ArtistID = tblAlbums.'.
Here is my Select statement. Can someone tell me what I'm doing wrong? I would very much appreciate it. Thanks!
SELECT a.tblAlbums.AlbumID,
a.tblAlbums.MediaType,
a.tblAlbums.ArtistID,
a.tblAlbums.Title,
a.tblArtists.ArtistID,
a.tblArtists.Artist,
a.tblArtists.The,
a.tblArtists.SortName,
a.tblTracks.AlbumID,
a.tblTracks.Title
FROM (tblArtists INNER JOIN tblAlbums ON
tblArtists.ArtistID = tblAlbums.ArtistID)
LEFT JOIN tblTracks ON tblAlbums.AlbumID = tblTracks.AlbumID WHERE (tblArtists.Artist LIKE '%Willie Nelson%' OR tblTracks.ArtistFullName LIKE '%Willie Nelson%')
ORDER BY tblArtists.SortName, tblAlbums.Title, tblTracks.Title, tblAlbums.MediaType a
(SELECT tblAlbums.Title,
tblAlbums.TitleSort,
tblAlbums.MediaType,
tblAlbums.AlbumID,
tblArtists.The, tblArtists.
Artist, tblArtists.ArtistID,
tblArtists.SortName
FROM tblArtists INNER JOIN tblAlbums
ON a.tblArtists.ArtistID = tblAlbums.ArtistID
ORDER BY tblArtists.SortName, tblAlbums.Title, tblTracks.Title, tblAlbums.MediaType b);
I'm trying to do a select within a select and having problems with it. First of all, let me explain the table structure I'm referencing.
tblArists can have 1 to many tblAlbums entries
tblAlbums can have 1 to many tblTracks entries
tblArtists and tblAlbums are joined by ArtistID
tblAlbums and tblTracks are joined by AlbumID
What I am trying to do is select artists who appear in the tblArtists.Artist or tblTracks.ArtistFullName fields in the database, then list only Artist, Album, and MediaType in a table. In order to do that, I need to do a select within a select. Here's the error I'm getting in my code:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'tblAlbums.MediaType a (SELECT tblAlbums.Title, tblAlbums.TitleSort, tblAlbums.MediaType, tblAlbums.AlbumID, tblArtists.The, tblArtists.Artist, tblArtists.ArtistID, tblArtists.SortName FROM tblArtists INNER JOIN tblAlbums ON a.tblArtists.ArtistID = tblAlbums.'.
Here is my Select statement. Can someone tell me what I'm doing wrong? I would very much appreciate it. Thanks!
SELECT a.tblAlbums.AlbumID,
a.tblAlbums.MediaType,
a.tblAlbums.ArtistID,
a.tblAlbums.Title,
a.tblArtists.ArtistID,
a.tblArtists.Artist,
a.tblArtists.The,
a.tblArtists.SortName,
a.tblTracks.AlbumID,
a.tblTracks.Title
FROM (tblArtists INNER JOIN tblAlbums ON
tblArtists.ArtistID = tblAlbums.ArtistID)
LEFT JOIN tblTracks ON tblAlbums.AlbumID = tblTracks.AlbumID WHERE (tblArtists.Artist LIKE '%Willie Nelson%' OR tblTracks.ArtistFullName LIKE '%Willie Nelson%')
ORDER BY tblArtists.SortName, tblAlbums.Title, tblTracks.Title, tblAlbums.MediaType a
(SELECT tblAlbums.Title,
tblAlbums.TitleSort,
tblAlbums.MediaType,
tblAlbums.AlbumID,
tblArtists.The, tblArtists.
Artist, tblArtists.ArtistID,
tblArtists.SortName
FROM tblArtists INNER JOIN tblAlbums
ON a.tblArtists.ArtistID = tblAlbums.ArtistID
ORDER BY tblArtists.SortName, tblAlbums.Title, tblTracks.Title, tblAlbums.MediaType b);