Last modified: 2014-02-24 21:54:44 UTC
https://tools.wmflabs.org/multichill/queries/wikidata/possible_merge.txt /* Make a list of items that might be mergable. Still have to filter out items that already have a link to the language */ connect wikidatawiki_p wikidatawiki.labsdb; SELECT CONCAT('* ', wbA.ips_site_page, ' - [[Q', wbA.ips_item_id, ']] & [[Q', wbC.ips_item_id, ']]') FROM wb_items_per_site AS wbA LEFT JOIN wb_items_per_site AS wbB ON (wbA.ips_item_id=wbB.ips_item_id AND NOT wbA.ips_site_id=wbB.ips_site_id) JOIN wb_items_per_site AS wbC ON (wbA.ips_site_page=wbC.ips_site_page AND NOT wbA.ips_site_id=wbC.ips_site_id) WHERE wbA.ips_site_id='nlwiki' AND wbB.ips_site_id IS NULL AND NOT EXISTS( SELECT * FROM wb_items_per_site AS wbD WHERE wbC.ips_item_id=wbD.ips_item_id AND wbD.ips_site_id='nlwiki');
If this query needs caching, the following is needed: a) caching for queries with parameters, or b) inter-database queries, or c) being able to override the database connection. If it doesn't, it can be implemented as a query with parameters.