How to select only those objects that have child relationship?
You can use a subquery to filter out Parent Records that don't have a related child,
eg
Select Id, Name from Account where Id In (Select AccountId from Contact)
In your case
Select Id, Name from Parent__c where Id In (Select ParentId__c from Child__c)
You can use a subquery in your where clause to only retrieve parents with children:
select Name, Parent_Field_1__c, Parent_Field_2__c
from Parent__c
where Id in (select Parent__c from Child_Object__c)
If you'd like to actually retrieve the child relationship records as well, you can do this in the same query by adding a subquery to your select
clause:
select Name, Parent_Field_1__c, Parent_Field_2__c,
(select Child_Field_1__c from Child__r)
from Parent__c
where Id in (select Parent__c from Child_Object__c)