SQL
x
/*set @page = 10069356;
select page_title from page
where (page_title = d
or page_title like concat(d, '_(%)'))
and not page_namespace;
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;*/
/*select page_title from page
where page_title in
(select 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)
and not page_namespace
and not exists
(select * from page_props
where page_id = pp_page
and pp_propname = "disambiguation")
order by page_title;*/
select c, i from
(select page_title as 'c', page_is_redirect as 'i' from page
where not page_namespace
and page_title like '%_(%)'
and not exists
(select * from page_props
where page_id = pp_page
and pp_propname = "disambiguation")
) t3
join
(select distinct(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
and not exists
(select * from page_props
where page_id = pp_page
and pp_propname = "disambiguation")) t0
order by a) t1
on c like concat(d, '_(%)')
order by c;
select page_title from page join page_props
on page_id = pp_page
where page_title = "Авиамоторная"
and pp_propname = "disambiguation"
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.