question

Thomas JR avatar image
0 Likes"
Thomas JR asked anthony.johnson commented

SQL NOT operator does not work

Hi folks,

the following SQL-query doesn't work for me (ignore the odd variable names):

  1. Table dummy = Table.query("SELECT SUM(Average*Count) FROM Input_data WHERE Variable = $1 AND Hello_world NOT IN ('Iphone', 'I like cats')", parameter_1);

However, when I remove the NOT operator, the query works fine. I believe the syntax is correct according to FlexSim documentation, so what's going on??

And FYI, I do not use any special characters for my original variable names, only what you'll find in the english alphabet.

FlexSim 20.1.3
flexsim 20.1.3sql queries
5 |100000

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

Benjamin W2 avatar image
1 Like"
Benjamin W2 answered anthony.johnson commented

Flexsim only supports a subset of SQL commands, and unfortunately, NOT is not one of them. You can see a list of what is supported here:

https://docs.flexsim.com/en/20.1/Reference/DeveloperAdvancedUser/SQLQueries/

Is there a way that you could create an array that your value is IN? You could then pass that array to the query.


· 3
5 |100000

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

martin.j avatar image
2 Likes"
martin.j answered Thomas JR commented

Hi @Thomas JR, I have been frustrated by the missing NOT clause as well, but managed to make a query similar to yours with a little workaround:

  1. Table dummy = Table.query("SELECT SUM(Average*Count) FROM Input_data WHERE Variable = $1 AND 1 <> (Hello_world IN ('Iphone', 'I like cats'))", parameter_1);

The IN keyword will return a true or false if the result is in the specified list/array, so if you specify that you want the result only where it is not true, it is practically the same as having a NOT statement. I admit that it is a bit clunky to read but it works.

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