|
|||||||
New to SitePoint Forums? Register here for free!
|
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
$this->toCD-R(LP);
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Dec 2003
Location: Federal Way, Washington (USA)
Posts: 1,627
|
Help needed with this SQL statement
I've got one last piece to this SQL statement that I can't quite figure out. I'm trying to do a union between three tables with the following characteristics.
tblArtists - one to many tblAlbums - each Artist can have one to many albums tblTracks - each Album can have one to many tracks What I want to do is list data by Artist and Album, where the lyrics id for an album track is a certain value. The following query works, but with the literal Where value just as you see it here (bolded for emphasis). I want to know what the Where clause should really look like. Thanks in advance for your help. Code:
( SELECT tblAlbums.Title AS albumtitle , tblAlbums.TitleSort , tblAlbums.MediaType AS format , tblAlbums.AlbumID AS albumid , tblArtists.The AS artist_the , tblArtists.Artist AS artist , tblArtists.ArtistID AS artistid , tblArtists.SortName AS sortname FROM tblArtists INNER JOIN tblAlbums ON tblArtists.ArtistID = tblAlbums.ArtistID WHERE tblArtists.Artist LIKE '%" . $this->where . "%' ) UNION ( SELECT tblAlbums.Title , tblAlbums.TitleSort , tblAlbums.MediaType , tblAlbums.AlbumID , tblArtists.The , tblArtists.Artist , tblArtists.ArtistID , tblArtists.SortName FROM tblTracks INNER JOIN tblAlbums ON tblTracks.AlbumID = tblAlbums.AlbumID INNER JOIN tblArtists ON tblAlbums.ArtistID = tblArtists.ArtistID WHERE tblTracks.Lyrics =30 ) ORDER BY sortname, albumtitle |
|
|
|
| Bookmarks |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
|
All times are GMT -7. The time now is 03:58.









Threaded Mode