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; SELECT table1.term_text, table1.epp_entity_id, table2.term_text, table2.epp_entity_id FROM ( SELECT * FROM pagelinks JOIN wb_entity_per_page ON pl_from = epp_page_id JOIN wb_terms ON term_entity_id = epp_entity_id WHERE pl_title IN ("Q202444","Q12308941","Q11879590") ) AS table1, (SELECT * FROM pagelinks JOIN wb_entity_per_page ON pl_from = epp_page_id JOIN wb_terms ON term_entity_id = epp_entity_id WHERE pl_title pl_title = "Q101352") AS table2 ) WHERE table1.term_text = table2.term_text; /* SELECT CONCAT("Q",epp1.epp_entity_id), links1.pl_title, terms1.term_text, terms2.term_text#, CONCAT("Q",epp2.epp_entity_id) 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 (SELECT * FROM wb_terms WHERE term_type = "label" AND term_entity_type = "item") AS terms1 CROSS JOIN (SELECT * FROM wb_terms WHERE term_type = "label" AND term_entity_type = "item") AS terms2 ON terms1.term_text = terms2.term_text 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...