SQL
x
set @page = 10069356;
select page_title from page join
(select a, locate('(', a) as 'c', if(locate('(', a) > 0, substring(a,1,locate('(', a)-2), a) as d from
(select pl_title as 'a' from pagelinks
where pl_from = @page
and not pl_namespace
union
select page_title as 'a' from page
where page_id in
(select tl_from from templatelinks
where tl_target_id = 21855)
and not page_namespace) t0
order by a)
where (page_title = d
or page_title like concat(d, '_(%)'))
and not page_namespace;
By running queries you agree to the Cloud Services Terms of Use and you irrevocably agree to release your SQL under CC0 License.
All SQL code is licensed under CC0 License.