Toggle navigation
Home
New Query
Recent Queries
Discuss
Database tables
Database names
MediaWiki
Wikibase
Replicas browser and optimizer
Login
History
Fork
This query is marked as a draft
This query has been published
by
Matěj Suchánek
.
Toggle Highlighting
SQL
USE wikidatawiki_p; # DESCRIBE wb_terms; SELECT CONCAT("Q",epp1.epp_entity_id), links1.pl_title, terms1.term_text, CONCAT("Q",epp2.epp_entity_id), terms2.term_text FROM wb_entity_per_page AS epp1 JOIN (SELECT * FROM pagelinks WHERE pl_title IN ("Q202444","Q12308941","Q11879590")) AS links1 ON links1.pl_from = epp1.epp_page_id LEFT JOIN (SELECT * FROM pagelinks WHERE pl_title = "P1533") AS links2 ON links2.pl_from = epp1.epp_page_id JOIN (SELECT * FROM wb_terms WHERE term_type = "label" AND term_entity_type = "item") AS terms1 ON terms1.term_entity_id = epp1.epp_entity_id CROSS JOIN (SELECT * FROM wb_terms WHERE term_type = "label" AND term_entity_type = "item") AS terms2 ON terms2.term_text = terms1.term_text JOIN wb_entity_per_page AS epp2 ON epp2.epp_page_id = terms2.term_entity_id JOIN (SELECT * FROM pagelinks WHERE pl_title = "Q101352") AS links3 ON links3.pl_from = epp2.epp_page_id WHERE links3.pl_from IS NULL GROUP BY epp1.epp_entity_id HAVING (COUNT(DISTINCT terms1.term_text) = 1 AND COUNT(DISTINCT terms2.term_text) = 1) LIMIT 100; /* SELECT * FROM wb_entity_per_page AS epp1 JOIN (SELECT * FROM pagelinks WHERE pl_title IN ("Q202444","Q12308941","Q11879590")) AS links1 ON epp1.epp_page_id = links1.pl_from JOIN (SELECT * FROM wb_terms WHERE term_type = "label" AND term_entity_type = "item") AS terms1 ON terms1.term_entity_id = epp1.epp_entity_id CROSS JOIN (SELECT * FROM wb_terms WHERE term_type = "label" AND term_entity_type = "item") AS terms2 ON terms2.term_text = terms1.term_text JOIN wb_entity_per_page AS epp2 ON epp2.epp_entity_page = terms2.term_entity_id JOIN (SELECT * FROM pagelinks WHERE pl_title = "Q101352") AS links2 ON links2.pl_from = epp2.epp_page_id WHERE NOT EXISTS ( SELECT * FROM pagelinks AS links3 WHERE links3.pl_from = epp1.epp_page_id AND links3.pl_title = "P1533" ) GROUP BY epp1.epp_entity_id HAVING (COUNT(DISTINCT terms1.term_text) = 1 AND COUNT(DISTINCT terms2.term_text) = 1) LIMIT 100; SELECT * FROM wb_entity_per_page AS epp1, wb_terms AS terms1, pagelinks AS links1, wb_terms AS terms2, wb_entity_per_page AS epp2, pagelinks AS links2 WHERE terms1.term_entity_id = epp1.epp_entity_id AND epp1.epp_page_id = links1.pl_from AND terms2.term_entity_id = epp2.epp_entity_id AND epp2.epp_page_id = links2.pl_from AND links1.pl_title IN ("Q202444","Q12308941","Q11879590") AND terms1.term_text = terms2.term_text AND links2.pl_title = "Q101352" AND NOT epp1.epp_page_id IN (SELECT pl_from FROM pagelinks WHERE pl_title = "P1533") GROUP BY epp1.epp_entity_id HAVING (COUNT(DISTINCT terms1.term_text) = 1 AND COUNT(DISTINCT terms2.term_text) = 1) LIMIT 100; */
By running queries you agree to the
Cloud Services Terms of Use
and you irrevocably agree to release your SQL under
CC0 License
.
Submit Query
Stop Query
All SQL code is licensed under
CC0 License
.
Checking query status...