How to query boolean use SQL?

LeoCui shared this question 3 years ago
Answered

mb.runSQLQuery(`


SELECT * FROM daily where index = true;


`).sort({date:-1})

.limit(100)

OR:

SELECT * FROM daily where index is true;

col 'index' is boolean,but when execute it , return messge:

{

"message" : "SyntaxError: Line: 1 Column: 32, Expected [A-Za-z0-9_:] or [A-Za-z0-9_] but ' ' found.",

"stack" : "script:2:4",

"sql" : "SELECT * FROM daily where index is TRUE )",

"___" : " ^ ",

"location" : {

"start" : {

"offset" : 31,

"line" : 1,

"column" : 32

},

"end" : {

"offset" : 32,

"line" : 1,

"column" : 33

}

}

}

Replies (1)

photo
1

Both of these methods are OK.


SELECT * FROM daily where index = TRUE

or

SELECT * FROM daily where index is TRUE
I noticed that there is an extra closing parenthesis in the SQL statement executed, which is not correct.

"sql" : "SELECT * FROM daily where index is TRUE )",

I can't reproduce the problem locally. Can you provide a complete reproduction step, including sample data and a complete script?


  1. NoSQLBooster Version e.g. 6.2.15
  2. Operating System e.g. macOS 10.13.6 / Windows 10 1803 / Ubuntu 18.04
  3. Expected Behavior
  4. Actual Behavior
  5. How to reproduce, include a sample JSON data and MongoDB script to reproduce the error quickly
  6. Screenshots


Leave a Comment
 
Attach a file