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.

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.

  1. Table.query("SELECT A FROM (SELECT A FROM table WHERE A = 1 LIMIT 2)\
  2.                         UNION ALL\
  3. 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.

  1. Table.query("SELECT A FROM table WHERE A = 1 LIMIT 2\
  2.                         UNION ALL\
  3.                         SELECT A FROM table WHERE A = 2 LIMIT 2\
  4.                         UNION ALL\
  5.                         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.