Inner query in soql can only happen for master-detail relationship or also for lookup relationship?
Inner query in case of master detail as below :
SELECT ID, (SELECT Amount FROM Opportunity) FROM Account;
You can do on both master-detail and lookup relationships. When writing an inner query you need to use the Child Relationship name of the master-detail/lookup relationship. For standard objects it's typically the plural name of the child object as per Lance's answer, however for custom relationships you define the Child Relationship name when you create the relationship and you need to always append
__r at the end:
[SELECT Id, (SELECT Id FROM MyCustomObject__r) FROM Account]