Template:Multiple values
Partial query to find items with several different main values for statements of one specified property. You can retrieve two sample value if you want.
Usage edit
{{Multiple values|P31}}
Generated fragment for items with several values for instance of (P31)
?item wdt:P31 ?item_P31_val1, ?item_P31_val2 filter(?item_P31_val1 != ?item_P31_val2) .
{{SPARQL|query=select ?multipleclass where { {{tl|multiple values|instance of|?multipleclass}} } limit 10 }}
The previous example in context, items with several values for instance of (P31) (click on "try it!")
select ?multipleclass where {
?multipleclass wdt:P31 ?multipleclass_instance_of_val1, ?multipleclass_instance_of_val2
filter(?multipleclass_instance_of_val1 != ?multipleclass_instance_of_val2) . } limit 10
Variable naming edit
The pattern is ?<class name><Pid or name>val1
and ?<class name><Pid or name>val2
for the two witness that there are different values. Their value is the value of the statement.
In the previous example you can retrieve the two values
{{SPARQL|query=select ?multipleclass ?multipleclass_instance_of_val1 ?multipleclass_instance_of_val2 where { {{tl|multiple values|instance of|?multipleclass}} } limit 10 }}
select ?multipleclass ?multipleclass_instance_of_val1 ?multipleclass_instance_of_val2 where {
?multipleclass wdt:P31 ?multipleclass_instance_of_val1, ?multipleclass_instance_of_val2
filter(?multipleclass_instance_of_val1 != ?multipleclass_instance_of_val2) . } limit 10
See also edit
{{Multiple statements}}
— Same but different statements that may have the same main value{{No statement}}
— no statement for a property
Partial query template to help write queries that search for items who have several values for a property (two statement with the same value count as only one value)
Parameter | Description | Type | Status | |
---|---|---|---|---|
property | 1 | the property Pid we want to have multiple main values for an item
| Unknown | required |
variable name | 2 subject | the variable name for the subject item
| Unknown | optional |
The above documentation is transcluded from Template:Multiple values/doc (edit | history). Editors can experiment in this template's sandbox (create | mirror) and testcases (create) page. Please add categories to the /doc subpage. Subpages of this template. |
?item wdt: ?item_{{{1}}}_val1, ?item_{{{1}}}_val2 filter(?item_{{{1}}}_val1 != ?item_{{{1}}}_val2) .