UNION not returning correct result
See original GitHub issueAlaSQL is based on unpaid voluntary work. Thank you for taking the time to make it better.
Question about how to …
Something is not working as expected:
-
Describe the problem
UNION does not work.
-
Provide code that replicates the problem
data1=[{a:'abc'},{a:'xyz'}]
data2=[{a:'123'},{a:'987'}]
alasql("select * from :a union select * from :b",{a:data1,b:data2})
— FF 95.01 Linux
[
{},
{},
{
"a": "abc"
},
{
"a": "xyz"
}
]
alasql.version “1.7.3-develop-0be167bcundefined”
----- Chrome 97.0 Linux
[
{},
{},
{
"a": "abc"
},
{
"a": "xyz"
}
]
alasql.version ‘1.7.3-develop-0be167bcundefined’
---- Node
> data1=[{a:'abc'},{a:'xyz'}]
[ { a: 'abc' }, { a: 'xyz' } ]
> data2=[{a:'123'},{a:'987'}]
[ { a: '123' }, { a: '987' } ]
>
> alasql("select * from :a union select * from :b",{a:data1,b:data2})
[ {}, {}, { a: 'abc' }, { a: 'xyz' } ]
> alasql.version
'1.7.3-develop-0be167bcundefined'
---- How does it work in sqlite3
sqlite> create table one(a text);
sqlite> create table two(a text);
sqlite> insert into a values('abc'),('def');
sqlite> insert into two values('xyz'),('123');
sqlite> select * from one union select * from two;
123
abc
def
xyz
- We suggest to spawn a jsfiddle from http://jsfiddle.net/98qL7m0c/
Maybe I’m using alasql incorrectly? I tried looking at some documentation in the wiki but the section on union is quite spartan.
Anyway, thanks a lot!
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
SQL returns less results when using UNION? - Stack Overflow
UNION will eliminate duplicate rows, whether they come between the two result sets or, as in your case, within just one result set....
Read more >Union Select ALL query not returning all rows - MSDN
Hi stifter, Both UNION and UNION ALL, instead of UNION SELECT ALL, concatenate the result of two different SQLs.
Read more >UNION not returning results - Oracle Communities
UNION not returning results ... In my query I get results from both the queries when run separately ... Probalbly union all will...
Read more >SELECT query using UNION does not return the rows ...
A SELECT query using UNION does not return the rows expected. Is there a way to confirm that a unique customer record existed...
Read more >How To Use Unions in SQL | DigitalOcean
The results returned through the UNION operation don't follow any particular order. To change that, you can utilize the ORDER BY clause. The ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Nice ! Thanks for the tips. 😄
Hello, sorry for giving no news.
Yep I’ve debugged a bit and it seems that the params of the first table are not passed to the union compilation method.
I’m still trying to understand all the compilation process of the query so I’m not sure where is the problem precisely.
I’m gonna work more on it this weekend. 😄