question

yexioamu avatar image
0 Likes"
yexioamu asked yexioamu commented

A bug of sql union all

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

FlexSim 21.2.4
sql
1.png (28.5 KiB)
2.png (25.2 KiB)
· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jacob W2 avatar image Jacob W2 ♦ commented ·

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 0 ·
yexioamu avatar image yexioamu Jacob W2 ♦ commented ·

how about now? my company account shares with me

0 Likes 0 ·

1 Answer

Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered yexioamu commented

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");
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

yexioamu avatar image yexioamu commented ·

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 0 ·