UNION function

623 views
Skip to first unread message

Fabrizio

unread,
Jul 26, 2012, 7:11:32 AM7/26/12
to orient-...@googlegroups.com

SELECT union(format("<td>%s</td<td>%s</td", Name, Surname)) AS Tabella
FROM Studente

Can I avoid "comma" character between each row? Or, how can I use "replace" function or other function about strings?

Fabrizio

Luca Garulli

unread,
Jul 26, 2012, 7:19:40 AM7/26/12
to orient-...@googlegroups.com
What commas? The commas inside the string or in the UNION function?

Lvc@



Fabrizio

--
 
 
 

Fabrizio

unread,
Jul 26, 2012, 7:36:10 AM7/26/12
to orient-...@googlegroups.com

Commas which UNION function append between two rows.
For example, if rows are

Hello World 1
Hello World 2
Hello World 3

UNION returns

Hello World 1, Hello World 2, Hello World 3

Can I avoid them? (for example modifying source code?)
Then can I use functions according to String.format() conventions?

Fabrizio

Luca Garulli

unread,
Jul 26, 2012, 7:39:11 AM7/26/12
to orient-...@googlegroups.com
Hi,
the Union just collects single results. probably you see the commas as a toString() of it.

If you need just a string as the sum of other stuff try using .append()

Lvc@



Fabrizio

--
 
 
 

Fabrizio

unread,
Jul 26, 2012, 7:48:53 AM7/26/12
to orient-...@googlegroups.com
 
I need to have
1) more fields of each row into a single field,
2) then a single field to collect all rows.

For example

| Name | Surname |                    |     Field  1 |                |               Field  2                   |
| AAA    |    BBB   |                    | AAA BBB |                |AAA BBB CCC DDD EEE FFF|
| CCC    |    DDD   |     ---->  1)    | CCC DDD |  ----> 2)
| EEE    |    FFF    |                    | EEE FFF |

In my query I get this but with commas (AAA BBB, CCC DDD, EEE FFF).

Fabrizio

Luca Garulli

unread,
Jul 26, 2012, 8:13:22 AM7/26/12
to orient-...@googlegroups.com
Hi,
you're right: a replace() is missing. Just created in SVN r6249. I've not tested yet behind a function like UNION:

SELECT union(format("<td>%s</td<td>%s</td", Name, Surname)).replace(",", " ") AS Tabella FROM Studente

Can you try it?

Lvc@



Fabrizio

--
 
 
 

Fabrizio

unread,
Jul 26, 2012, 8:44:37 AM7/26/12
to orient-...@googlegroups.com
I'm sorry for the question: do I need to update something to try it? What's "SVN r6249"?

Fabrizio

Luca Garulli

unread,
Jul 26, 2012, 8:55:33 AM7/26/12
to orient-...@googlegroups.com
If you don't know about SVN release, just use latest 1.2.0-SNAPSHOT from Maven Central repository deployed minutes ago.

Lvc@

On 26 July 2012 14:44, Fabrizio <fabrizio....@libero.it> wrote:
I'm sorry for the question: do I need to update something to try it? What's "SVN r6249"?

Fabrizio

--
 
 
 

Fabrizio

unread,
Jul 26, 2012, 9:59:33 AM7/26/12
to orient-...@googlegroups.com

https://oss.sonatype.org/content/groups/public/com/orientechnologies/orientdb/1.2.0-SNAPSHOT/

In this page, I downloaded this file zip: orientdb-1.2.0-20120726.123215-2-distribution.zip
Then I copied my database into "databases" folder.
Is it correct?

Luca Garulli

unread,
Jul 26, 2012, 10:03:31 AM7/26/12
to orient-...@googlegroups.com
Hi,
no copy the libs (*.jar) under the lib/ folder.

Lvc@



--
 
 
 

Fabrizio

unread,
Jul 26, 2012, 10:11:41 AM7/26/12
to orient-...@googlegroups.com

There is a problem with the server:
"Server is shutdowning"

Fabrizio

Shishya

unread,
Mar 6, 2014, 6:10:41 AM3/6/14
to orient-...@googlegroups.com
Hi,

Is union there in v1.7rc2SS. I m getting this error

 No function for name union, available names are : [asdate,ifnull,both,last,count ,distinct ,substring, avg,right,dijkstra,encode,append,coalesce,eval,ine,label,format,asdatetime,include,difference,asdecimal,decode,sysdate,intersect,inv, outv,multivalue,charat,set,sum,convert,bothv,SWITCH,date,shortestpath,document,distance,if,gremlin,length,map,left,bothe,min,GY2,max,list,exclude,tojson,in,SEARCH1,replace, unionall ,oute,first,out]

Andrey Lomakin

unread,
Mar 6, 2014, 6:28:00 AM3/6/14
to orient-database
What is your query ?

Guys, could you provide full information, like:
1. detailed use case 
2. thrown exception if any.
3. test case or sample db if needed or possible.

Otherwise we spend time on discovering details instead of problem solving :-) .


--

---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Best regards,
Andrey Lomakin.

Orient Technologies
the Company behind OrientDB

Damian Bronecki

unread,
Mar 6, 2014, 7:12:48 AM3/6/14
to orient-...@googlegroups.com
In 1.7 "union" is replaced by "unionall"

prabhat

unread,
Mar 6, 2014, 7:43:31 AM3/6/14
to orient-...@googlegroups.com
Thanks Damian,

I tried using unionall but it gives an object. 
My query is 
select unionall(id,year),month from #11:111
I get
----+-----+--------+---------
#   |@RID |unionall|month

----+-----+--------+---------
0   |#-2:1|[2]     |sep 

----+-----+--------+---------

When I try this, I get
select unionall(id,year).toString(),month from #11:111
----+-----+-------------------------------------------------------------------------+---------
#   |@RID |unionall                                                                 |month

----+-----+-------------------------------------------------------------------------+---------
0   |#-2:1|com.orientechnologies.common.collection.OMultiCollectionIterator@74f8e04c|sep 

----+-----+-------------------------------------------------------------------------+---------


While I expect, concated string of id and year. Any help please?

Thanks





On Thu, Mar 6, 2014 at 5:42 PM, Damian Bronecki <broneck...@gmail.com> wrote:
In 1.7 "union" is replaced by "unionall"

--

---
You received this message because you are subscribed to a topic in the Google Groups "OrientDB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/orient-database/iaKYKI81fKY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to orient-databa...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages