title: SPARQL: combine multiple predicate values into array of labels
body: <p>Right now I have a query that returns a list of various properties for a specific entity:</p>
  
  <pre><code>SELECT ?propLabel ?val WHERE {
  
    BIND(wd:Q122426 as ?entity)
    {
      BIND(?entity AS ?valUrl)
      BIND("n/a" AS ?propUrl)
      BIND("name"@en AS ?propLabel)
      ?entity rdfs:label ?val.
      FILTER((LANG(?val)) = "en")
  
  # instance of
    } UNION {
      ?entity wdt:P31 ?valUrl .
      BIND("instance of"@en AS ?propLabel)
  
      # filter  isIRI(?valUrl) 
      ?valUrl rdfs:label ?valLabel 
      FILTER (LANG(?valLabel) = "en") 
      BIND(CONCAT(?valLabel) AS ?val)
  
  # occupation
    } UNION {
      ?entity wdt:P106 ?val.
      BIND("occupation"@en AS ?propLabel)
  
  # position held
    } UNION {
      ?entity wdt:P39 ?val.
      BIND("position"@en AS ?propLabel)
  
  # ... and more ...
  
    }
  }
  </code></pre>
  
  <p>This works great, but it returns the entity code (Qxxxxx) instead of the text label. So I can change it like this:</p>
  
  <pre><code># occupation
    } UNION {
      ?entity wdt:P106 ?valUrl.
      BIND("occupation"@en AS ?propLabel)
  
      ?valUrl rdfs:label ?valLabel 
      FILTER (LANG(?valLabel) = "en") 
      BIND(CONCAT(?valLabel) AS ?val)
  </code></pre>
  
  <p>and that works fine.</p>
  
  <h1>But my question is</h1>
  
  <p>How can I 'collapse' the values for multiple predicates into a string? i.e. for the predicates P106, P119, Px, Py, etc. get:</p>
  
  <pre><code>| ?property   | ?valueLabel |
  |-------------+-------------|
  | tags  | politician, Giza East Field, something else, something else |
  | name        | Henutsen    |
  </code></pre>
  
  <p>Is there a more efficient way to structure the query rather than <code>UNION</code>ing every predicate? Like, supply just a list of predicates <code>P31, P106, P39</code> etc</p>