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 first_names.term_text, first_names.epp_entity_id FROM ( SELECT term_text, epp_entity_id FROM (SELECT * FROM pagelinks WHERE pl_title IN ("Q3409032","Q12308941","Q11879590") AND pl_from_namespace = 0) AS pl1 JOIN wb_entity_per_page ON pl_from = epp_page_id JOIN (SELECT * FROM wb_terms WHERE term_type = "label" AND term_entity_type = "item" AND term_text NOT LIKE '% %') AS labels ON term_entity_id = epp_entity_id LEFT JOIN (SELECT * FROM pagelinks WHERE pl_title = "P1533" AND pl_namespace = 120) AS withoutP1533 ON withoutP1533.pl_from = epp_page_id WHERE withoutP1533.pl_title IS NULL ) AS first_names, ( SELECT term_text, epp_entity_id FROM (SELECT * FROM pagelinks WHERE pl_title = "Q101352" AND pl_from_namespace = 0) AS links JOIN wb_entity_per_page ON pl_from = epp_page_id JOIN (SELECT * FROM wb_terms WHERE term_type = "label" AND term_entity_type = "item") AS labels ON term_entity_id = epp_entity_id ) AS surnames WHERE surnames.term_text = first_names.term_text GROUP BY first_names.term_text HAVING COUNT(DISTINCT first_names.term_text) = 1 AND COUNT(DISTINCT surnames.term_text) = 1 ORDER BY first_names.term_text;*/ SELECT /*first_name_labels.term_text,*/ CONCAT("Q",first_name_labels.term_entity_id), surname_labels.term_text, CONCAT("Q",surname_labels.term_entity_id) FROM (SELECT * FROM pagelinks WHERE pl_title = "Q101352" AND pl_from_namespace = 0) AS surnames JOIN wb_entity_per_page AS epp1 ON epp1.epp_page_id = surnames.pl_from JOIN (SELECT * FROM wb_terms WHERE term_type = "label" AND term_entity_type = "item") AS surname_labels ON surname_labels.term_entity_id = epp1.epp_entity_id # JOIN (SELECT * FROM wb_terms WHERE term_type = "label" AND term_entity_type = "item") AS first_name_labels # ON first_name_labels.term_text = surname_labels.term_text # AND first_name_labels.term_language = surname_labels.term_language # JOIN wb_entity_per_page AS epp2 # ON epp2.epp_entity_id = first_name_labels.term_entity_id #JOIN (SELECT * FROM pagelinks WHERE pl_title IN ("Q3409032","Q12308941","Q11879590") AND pl_from_namespace = 0) AS first_names # ON first_names.pl_from = epp2.epp_page_id #LEFT JOIN (SELECT * FROM pagelinks WHERE pl_title = "P1533" AND pl_namespace = 120) AS withoutP1533 # ON withoutP1533.pl_from = epp2.epp_page_id #WHERE withoutP1533.pl_from IS NULL GROUP BY first_name_labels.term_entity_id LIMIT 10;
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...