Search code examples
wikidatawikidata-query-service

Get the complete info of a Wikidata item


I'm using the following query to get the info of a specific Wikidata item.

For example, this one gets the info about the movie Titanic

SELECT ?wd ?wdLabel ?ps ?ps_Label ?wdpqLabel ?pq_Label {
VALUES (?film) {(wd:Q44578)}

?film ?p ?statement .
?statement ?ps ?ps_ .

?wd wikibase:claim ?p.
?wd wikibase:statementProperty ?ps.

OPTIONAL {
?statement ?pq ?pq_ .
?wdpq wikibase:qualifier ?pq .
}

SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }

} ORDER BY ?wd ?statement ?ps_

It works well and I do get the info, but I want to add the items ("Q") beside them. For example, if the genre is "romance film" I would like to get Q1054574 besides it. And if the actor is Leonardo DiCaprio I would like to get Q38111.

How can I achieve this in this kind of query?


Solution

  • You could add ?ps_ to the SELECT:

    SELECT ?wd ?wdLabel ?ps ?ps_Label ?ps_ ?wdpqLabel ?pq_Label
    

    Result: Screenshot