Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I am wanting to display information on a webpage about my music collection.
I have 3 tables, music_info, genres and mediums.
within the music_info table it references the genre and medium through an ID number which coresponds to a record within the genre and medium tables.
i want to obtain all of this information so that i can display it all on the webpage.
I have used JOIN to do part of this shown below:
SELECT music_info.*, genres.*
FROM music_info
INNER JOIN genres
ON music_info.genreID = genres.genreIDI want to be able to include the medium in the statement aswell so that i can use it to display it on the webpage.
I thought maybe i could use the sql shown below to do this but doesnt seem to work in that way.
SELECT music_info.*, genres.*, medium.*
FROM music_info
INNER JOIN genres
ON music_info.genreID = genres.genreID
AND INNER JOIN mediums
ON music_info.mediumID = mediums.mediumIDanyone know how i can obtain all the infromation from all tables in one SQL statement.
I am using ASP and Microsoft Access on IIS (Win XP Pro)
Thanks
Chris

You almost got it...Just get rid of the AND.
SELECT music_info.*, genres.*, medium.*
FROM music_info
INNER JOIN genres
ON music_info.genreID = genres.genreID
INNER JOIN mediums
ON music_info.mediumID = mediums.mediumIDI think the inner join is probably the right choice here, assuming all rows in the music_info table have associated genres and mediums.
Good luck,
-SN

I thought that myself and i tried that.
However i am still getting this error:
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'music_info.genreID = genres.genreID INNER JOIN mediums ON music_info.mediumID = mediums.mediumID'.
/music/index.asp, line 42i get this when i use the following statement:
strSQL = "SELECT music_info.*, genres.*, mediums.* FROM music_info INNER JOIN genres ON music_info.genreID = genres.genreID INNER JOIN mediums ON music_info.mediumID = mediums.mediumID"
any ideas?
Thanks
Chris

Hmmm...Maybe Access requires parens:.
SELECT music_info.*, genres.*, mediums.* FROM (music_info INNER JOIN genres ON music_info.genreID = genres.genreID) INNER JOIN mediums ON music_info.mediumID = mediums.mediumID
Good luck,
-SN

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |