Hello again,

this time I would like to ask about another problem/ challenge that I am facing.

I want to be able to merge the values of multiple variables into one. To make it more clear I want to do something like ?a + ?b + .... the problem however is that the bindings are URIS and not numbers.

For example:

?subject_1 Some_predicate ?object_1
blah blah blah...
?subject_n Some_predicate ?object_n

Till now I am doing this trick with COALESCE function. I know that this function was not meant for it, however there are times that works perfectly and when for example I write: BIND(COALESCE(?object_1, ?object_2) AS ?object_total) then I am find in ?object_total all the binds that the other two variables made. However this doesn't work always.


I made a very small but crucial mistake on the title, the correct title should be: How to merge values of different variables into one VARIABLE?

So I am not looking to concatenate multiple values together. What I am looking for is the following:

?object_1 has inside it: URI_1, URI_2, URI_3
?object_2 has inside it: URI_4, URI_5, URI_3
?object_3 has inside it: URI_6, URI_5, URI_7

I want a new created variable that is a distinct union of the three upper variables and has inside it:

?object_all: URI_1, URI_2, URI_3, URI_4, URI_5, URI_6, URI_7

asked 13 Nov '12, 17:00

Christos's gravatar image

accept rate: 33%

edited 14 Nov '12, 11:04

Signified's gravatar image

Signified ♦

I am suspecting that you are looking for the CONCAT function, but can you be more concrete? That is: show the actual input values and what you want the eventual output to look like.

(13 Nov '12, 17:21) Jeen Broekstra ♦ Jeen%20Broekstra's gravatar image

You can't use COALESCE to achieve your goal because that returns the first non-error value of it's arguments. I really don't understand why you are trying to do this in the first place? If ?object_1, ?object_2 etc are originating from different graph patterns in your query you would be better to just call them all ?object and UNION the different graph patterns together.

(13 Nov '12, 19:14) Rob Vesse ♦ Rob%20Vesse's gravatar image

Btw if you have a significant change/clarification to your question please edit the question don't add a huge comment! I've done this for you this time.

(13 Nov '12, 19:14) Rob Vesse ♦ Rob%20Vesse's gravatar image

Just to flesh out @Rob's suggestion in his comment: use UNION.

   { ?subject_1 Some_predicate ?object }
   { ?subject_n Some_predicate ?object }
permanent link
This answer is marked "community wiki".

answered 14 Nov '12, 11:08

Signified's gravatar image

Signified ♦
accept rate: 37%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 13 Nov '12, 17:00

question was seen: 920 times

last updated: 14 Nov '12, 11:08