User:Lectrician1/Queries/track external id values

From Wikidata
Jump to navigation Jump to search

  1. Get items with specified properties and their values in separate columns

SELECT ?item

      (GROUP_CONCAT(DISTINCT ?spotify; SEPARATOR="|") AS ?spotify_values)
      (GROUP_CONCAT(DISTINCT ?apple_music; SEPARATOR="|") AS ?apple_music_values)
      (GROUP_CONCAT(DISTINCT ?youtube; SEPARATOR="|") AS ?youtube_values)
      (GROUP_CONCAT(DISTINCT ?pandora; SEPARATOR="|") AS ?pandora_values)
      (GROUP_CONCAT(DISTINCT ?deezer; SEPARATOR="|") AS ?deezer_values)
      (GROUP_CONCAT(DISTINCT ?tidal; SEPARATOR="|") AS ?tidal_values)
      (GROUP_CONCAT(DISTINCT ?soundcloud; SEPARATOR="|") AS ?soundcloud_values)

WHERE {

 #VALUES ?item { wd:Q107026056 }
 ?item wdt:P279*/wdt:P31 wd:Q7302866.
 OPTIONAL {
   ?item wdt:P2207 ?spotify.       # Spotify Track ID
 }
 OPTIONAL {
   ?item wdt:P10110 ?apple_music. # Apple Music Track ID
 }
 OPTIONAL {
   ?item wdt:P1651 ?youtube.      # YouTube Video ID
 }
 OPTIONAL {
   ?item wdt:P10136 ?pandora.     # Pandora Track ID
 }
 OPTIONAL {
   ?item wdt:P2724 ?deezer.       # Deezer Track ID
 }
 OPTIONAL {
   ?item wdt:P4578 ?tidal.        # Tidal Track ID
 }
 OPTIONAL {
   ?item wdt:P3040 ?soundcloud.   # SoundCloud ID
 }
 # Check if the item does not have all the specified properties
 
 FILTER (!(BOUND(?spotify) && BOUND(?apple_music) && BOUND(?youtube) && BOUND(?pandora) && BOUND(?deezer) && BOUND(?tidal) && BOUND(?soundcloud)))

} GROUP BY ?item

LIMIT 100