12select.mql 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. -- ============================================================
  2. -- Select 查询操作测试
  3. -- ============================================================
  4. -- 1. 全表查询
  5. select * from /test/aaa/test_basic
  6. /**
  7. output()
  8. match("insert_001","hello world 测试数据")
  9. **/
  10. ;
  11. -- 2. 等值查询
  12. select * from /test/aaa/test_basic where name='insert_001'
  13. /**
  14. output()
  15. count(1)
  16. match("v_int","100")
  17. **/
  18. ;
  19. -- 3. 多字段条件查询(AND)
  20. select name, v_int, v_bool from /test/aaa/test_basic where name='insert_001' and v_int=100
  21. /**
  22. output()
  23. count(1)
  24. **/
  25. ;
  26. -- 4. OR 条件查询
  27. select * from /test/aaa/test_basic where name='insert_001' or name='insert_002'
  28. /**
  29. output()
  30. count(2)
  31. **/
  32. ;
  33. -- 5. 大于条件查询
  34. select name, v_int from /test/aaa/test_basic where v_int>10
  35. /**
  36. output()
  37. **/
  38. ;
  39. -- 6. 小于条件查询
  40. select name, v_int from /test/aaa/test_basic where v_int<0
  41. /**
  42. output()
  43. match("insert_004")
  44. **/
  45. ;
  46. -- 7. 大于等于条件
  47. select name, v_int from /test/aaa/test_basic where v_int>=100
  48. /**
  49. output()
  50. **/
  51. ;
  52. -- 8. 不等于条件
  53. select name, v_int from /test/aaa/test_basic where name!='insert_001'
  54. /**
  55. output()
  56. **/
  57. ;
  58. -- 9. 查询 bool 字段
  59. select name, v_bool from /test/aaa/test_basic where v_bool=true
  60. /**
  61. output()
  62. match("insert_001")
  63. **/
  64. ;
  65. select name, v_bool from /test/aaa/test_basic where v_bool=false
  66. /**
  67. output()
  68. **/
  69. ;
  70. -- 10. 带 LIMIT 的查询
  71. select * from /test/aaa/test_basic limit 3
  72. /**
  73. output()
  74. count(3)
  75. **/
  76. ;
  77. -- 11. 查询不存在的记录
  78. select * from /test/aaa/test_basic where name='non_exist_key_99999'
  79. /**
  80. output()
  81. count(0)
  82. **/
  83. ;
  84. -- 12. 查询 version 表
  85. select * from /test/aaa/test_basic_ver where name='ver_001'
  86. /**
  87. output()
  88. count(1)
  89. **/
  90. ;
  91. -- 13. 查询 float/double 字段
  92. select name, v_float, v_double from /test/aaa/test_basic where name='insert_001'
  93. /**
  94. output()
  95. **/
  96. ;
  97. -- 14. 查询 bigint 字段
  98. select name, v_bigint from /test/aaa/test_basic where name='insert_003'
  99. /**
  100. output()
  101. match("v_bigint","9223372036854775807")
  102. **/
  103. ;