Where Method
The where method is used to query data that matches specified conditions.

Returns: ml.data.query.Query Syntax .where(columnName: string, operator: string, value: any) Optional Parameter for applying where filter before the groupby .where(columnName: string, operator: string, value: any, whereFirst?: boolean)
ParameterDescription
Column NameName of column
OperatorString value that represents one of the available operators (link to table below).
ValueValue data will be compared against
whereFirstOptional Boolean for applying where filter before the groupby.
Example
  1. var q = ml.query();
  2. q.select('LowRate').from('hms/hotels');
  3. q.where('LowRate','GreaterOR',100);
  4. q.run(function(data){
  5. console.log(data);
  6. });
Demo
  1. <html>
  2. <head>
  3. <script type="text/javascript" src="/JS"></script>
  4. <script type="text/javascript">
  5. ml.onload(function () {
  6.  
  7. //create ml.query()
  8. var q = ml.query();
  9. q.select('LowRate').from('hms/hotels');
  10. q.where('LowRate','GreaterOR',450).where('LowRate','LessOR',500);
  11. //Take defaults to 100 if not included
  12. q.take(10);
  13. q.run(function(data){
  14. console.log(data);
  15. //Show the data as an html table
  16. displayTable(document.getElementById("dataDiv"),data);
  17. });
  18.  
  19. });
  20.  
  21. function displayTable(dataDiv, data){
  22. var rows = ml.data.query.Query.transposeQueryData(data.data);
  23. console.log(rows);
  24. var head = [];
  25. ml.each(rows[0], function(k,v) {
  26. head.push(k);
  27. });
  28. rows.unshift(head);
  29. data=rows;
  30. var table = ml.$("<table/>").addClass('CSSTableGenerator');
  31. ml.$.each(data, function(rowIndex, r) {
  32. var row = ml.$("<tr/>");
  33. ml.$.each(r, function(colIndex, c) {
  34. var content = "<p>"+c+"</p>";
  35. row.append(ml.$("<t"+(rowIndex == 0 ? "h" : "d")+"/>").html(content));
  36. });
  37. table.append(row);
  38. });
  39.  
  40. ml.$(dataDiv).html(table);
  41. }
  42. </script>
  43. <style>
  44. table tr:nth-child(even) {
  45. background-color: #eee;
  46. }
  47. table tr:nth-child(odd) {
  48. background-color:#fff;
  49. }
  50. table th {
  51. background-color: black;
  52. color: white;
  53. padding: 4px;
  54. }
  55. table td {
  56. padding: 4px;
  57. }
  58. </style>
  59. </head>
  60. <body>
  61. <div id="dataDiv"></div>
  62. </body>
  63. </html>
Comparison Operators
Filter can be applied to columns of type (D = Double, I = Int32, S = String)
Name D I S Description
Between   Column row values between a minimum and maximum, inclusive.
Bottom   A given number of smallest column row values.
Contains     Column rows that contain a value, as a substring. [Not Case Sensitive], [commas are valid search terms]
ContainsAll     Column rows that contain all of a list of values, as a substring. [Not Case Sensitive], [list is comma delimited and commas are NOT valid search terms]
ContainsAny     Column rows that contain any of a list of values, as a substring. [Not Case Sensitive], [list is comma delimited and commas are NOT valid search terms]
ContainsNot     Column rows that do not contain a single value as a sub string [Not Case Sensitive], [commas are valid search terms]
ContainsNone     Column rows that do not contain any of a list of values, as a substring. [Not Case Sensitive], [list is comma delimited and commas are NOT valid search terms]
ContainsOr     Column rows that contain any of a list of values, as a substring. Alias for “ContainsAny” [Not Case Sensitive], [list is comma delimited and commas are NOT valid search terms]
Equal Column rows that equal exactly some value. [Case Sensitive]
EqualAny Column rows that equal any of a list of values. [Case Sensitive]
EqualNone   Column rows that do not equal any of a list of values. [Case Sensitive]
EqualNot Column rows that do not equal a value exactly. [Case Sensitive]
Greater   Column rows whose values are strictly greater than some value.
GreaterOR   Column rows whose values are greater than or equal to some value.
Less   Column rows whose values are strictly less than some value.
LessOR   Column rows whose values are less than or equal to some value.
NotBetween   Column row values not between a min and max, inclusive.
Top   A given number of largest column row values.