I am trying to extract pages in Wikisource which contain a particular template. I have the page table, the templatelinks table, but can't find the table which stores the template names.
Topic on Talk:Quarry
Templates are also pages in page table. The tl_namespace and tl_title columns are pointers back to the page_namespace and page_title columns of the page table. The "Template" namespace is namespace 10. So if you wanted to find pages in the main namespace that transclude the Template:Table_style template:
USE enwikisource_p;
SELECT page_title
FROM templatelinks
LEFT JOIN page ON (tl_from = page_id AND tl_from_namespace = page_namespace)
WHERE tl_namespace = 10
AND tl_title = 'Table_style'
AND tl_from_namespace = 0;
Much thanks, I guess you saw me struggling with it. :-)