I want to know how to get the lists from all SubSites with the same name using SP query.
Thanks in advance.
To achieve your requirement, you could create a page and add search box web part and search results web part.
And then edit the search results web part and add the query below. You could add all sub sites as the format Path:”http://sp:20971/subsite1”.
And save the changes in the search results web part and save the changes in the page.
Then you could type the list name in the search box, it will return the lists with the same list name from all sub sites.