A bug of sql union all

A bug of sql union all

yexioamu
Not applicable
802 Views
4 Replies
Message 1 of 5

A bug of sql union all

yexioamu
Not applicable

[ FlexSim 21.2.4 ]

a bug of union all sql.fsmWhen i create a GlobalTable ,then use union all, the rows of result is incorrect, it is the last select limit nums。

what can i do for it?

1.png 2.png

0 Likes
Accepted solutions (1)
803 Views
4 Replies
Replies (4)
Message 2 of 5

Jacob_White
Community Manager
Community Manager

Hi @yexioamu,

Thank you for contributing to our community! We couldn't identify a maintained license or subscription linked to your account.

You may need to update your profile information to identify yourself as a license owner or their associate. Check out our article for how to ensure you receive timely support. If you update your profile comment back to let us know - we'll adjust the priority of your post accordingly.

If your current license is expired, please contact your local distributor to renew.

0 Likes
Message 3 of 5

yexioamu
Not applicable

how about now? my company account shares with me

0 Likes
Message 4 of 5

FelixMoehlmann
Collaborator
Collaborator
Accepted solution

I have found two possible workarounds:

Nest the select clauses in another select that simply copies the results.

Table.query("SELECT A FROM (SELECT A FROM table WHERE A = 1 LIMIT 2)\
                        UNION ALL\ SELECT A FROM (SELECT A FROM table WHERE A = 2 LIMIT 2)");

Or add an extra select clause at the end that you know won't return anything but doesn't have a limit.

Table.query("SELECT A FROM table WHERE A = 1 LIMIT 2\
                        UNION ALL\                         SELECT A FROM table WHERE A = 2 LIMIT 2\                         UNION ALL\                         SELECT A FROM table WHERE A = -1 AND A = 1");
0 Likes
Message 5 of 5

yexioamu
Not applicable

It works well, thx!

Although this operation may seem a bit strange, it does not comply with SQLite syntax, then we use a complex method to avoid it

0 Likes