I have the current SPARQL code:
SELECT ?currentQid ?propQid ?targetQid WHERE
{
VALUES ?current {wd:Q5 wd:Q6 wd:Q7 wd:Q8 wd:Q9}
VALUES ?prop {wdt:P31 wdt:P279 wdt:P361}
BIND (STRAFTER(STR(?current), STR(wd:)) AS ?currentQid)
BIND (STRAFTER(STR(?prop), STR(wdt:)) AS ?propQid)
BIND (STRAFTER(STR(?target), STR(wd:)) AS ?targetQid)
?current ?prop ?target.
}
ORDER BY ASC (?currentQid)
Which outputs
currentQid propQid targetQid
Q5 P31 Q55983715
Q5 P279 Q154954
Q5 P279 Q215627
Q5 P361 Q1156970
Q8 P31 Q331769
Q8 P31 Q60539479
Q8 P279 Q16748867
However, I wanted to also have the current index of the value, so I can correctly attribute the values to the array's item when I get the JSON.
How could I get the following table?
index currentQid propQid targetQid
0 Q5 P31 Q55983715
0 Q5 P279 Q154954
0 Q5 P279 Q215627
0 Q5 P361 Q1156970
3 Q8 P31 Q331769
3 Q8 P31 Q60539479
3 Q8 P279 Q16748867