質問

http://i1078.photobucket.com/albums/w499/Stephanie_Faith_Feliciano/table_zps180da26a.png

Hi i have three tables here the table appxserv contains foreign keys. what i need is to select all the services of a given application. meaning in 1 application it will show all the services that it has.

Thank you!

so for example application 1 will therefore show serv1 and serv2. I just need the sql statement

役に立ちましたか?

解決

This can be easily achieved using a nested inner join, for your example this would be:

SELECT * FROM (application_table INNER JOIN appxserv ON application_table.id = appxserv.app_id) 
INNER JOIN service_table ON appxserv.serv_id = service_table.id 
WHERE appname = "app1" 

You can change your WHERE statement to use id's or something as well ofcourse.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top