表达式

内置 SQL 支持算术表达式、比较表达式。

算术表达式

格式

[mathematical\_operator](http://doc.sequoiadb.com/cn/SequoiaDB-cat_id-1520813531-edition_id-302#%E7%AE%97%E6%9C%AF%E8%BF%90%E7%AE%97%E7%AC%A6)\

Note:

支持复合运算,如 select ( a + 1 ) * ( a - 1 ), b + 1 from foo.bar

示例

age字段值加一

  1. age + 1

取集合中age字段,age值加1

  1. > db.exec( "select age + 1 from foo.bar" )
  2. {
  3. "age": 12
  4. }

比较表达式

格式

[comparison\_operator](http://doc.sequoiadb.com/cn/SequoiaDB-cat_id-1520813531-edition_id-302#%E6%AF%94%E8%BE%83%E8%BF%90%E7%AE%97%E7%AC%A6)\

[comparison\_operator](http://doc.sequoiadb.com/cn/SequoiaDB-cat_id-1520813531-edition_id-302#%E6%AF%94%E8%BE%83%E8%BF%90%E7%AE%97%E7%AC%A6)\ [logical\_operator](http://doc.sequoiadb.com/cn/SequoiaDB-cat_id-1520813531-edition_id-302#%E9%80%BB%E8%BE%91%E8%BF%90%E7%AE%97%E7%AC%A6)\

示例

  • age字段大于11

    1. age > 11

    查询匹配age大于11的记录。

    1. > db.exec( "select * from foo.bar where age > 11" )
    2. {
    3. "_id": {
    4. "$oid": "5aa3330fdc5673331f000000"
    5. },
    6. "name": "Lucy",
    7. "age": 12
    8. }
  • age字段大于等于11,且name为Harry

    1. age >= 11 AND name = 'Harry'

    查询匹配age大于等于11,且name为Harry的记录。

    1. > db.exec( "select * from foo.bar where age >= 11 AND name = 'Harry'" )
    2. {
    3. "_id": {
    4. "$oid": "5aa35dbedc5673331f000001"
    5. },
    6. "name": "Harry",
    7. "age": 11
    8. }