Reputation: 8541
How would I go about to list any duplicate values for a property in Semantic MediaWiki? A MySQL query would do fine, it doesn't have to be through a SMW query.
Upvotes: 2
Views: 227
Reputation: 8541
I found a way that works for me:
With Extension:Variables installed, create a template {{Detect duplicates}}
like this:
{{#ifeq:{{#var:a}}|{{#vardefineecho:a|{{{2|}}}}}|<!--
Found a duplicate! Print some message:
-->Duplicate found: {{{2}}}<!--
Not a duplicate, do nothing
-->|}}
and ask for values like this:
{{#ask:[[MyProperty::+]]
|?MyProperty
|sort=MyProperty
|format=template
|template=Detect duplicates
}}
It is important to sort the results before sending them to the template, as the duplicate has to come next to each others.
Upvotes: 2