MySQL Forums
Forum List  »  Newbie

can i get to the information i want using just one statement?
Posted by: ioloop
Date: March 24, 2005 05:57PM

im relatively new to mysql so go easy ;)

i have a 3 tables:

artists (ID,artistName,linkerID)
releases (ID,releaseName, artistName)
linker (ID,linkerID)

artists may record under many aliases (i.e. the same artist appears in the artists table more than once with a different artistName but each time has the same linkerID)

i want to users to be able to search for releases by a particular artist and be returned all releases for that artist including the releases under different aliases.

the only way i can think of returning this information is by using three sequential statements:


SELECT linkerID FROM artists WHERE artistName = '$userSearchVar'

then using that result in the following statement..

SELECT artistname FROM artists WHERE linkerID = '$queryResult1'

then iterating through the results from the above statement using the following ..

SELECT * FROM releases WHERE artistname = '$queryresult2[]'


is this the most efficient way of doing it? is there something more clever i can do using joins or nested clauses??

Options: ReplyQuote


Subject
Written By
Posted
can i get to the information i want using just one statement?
March 24, 2005 05:57PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.