
op.fromSQL( select as String, [qualifier as String] ) as ModifyPlan
This function dynamically constructs a row set based on a SQL SELECT query from views.
| Parameters | |
|---|---|
| select | A SQL SELECT query expressed as a string. | 
| qualifier | Specifies a name for qualifying the column names. Placeholder parameters in the SQL string may be bound in the result() call. | 
    The fromSQL function is one of the
    Data Access Functions.
     
// List all of the employees in the 'employees' view.
const op = require('/MarkLogic/optic');
  op.fromSQL('SELECT employees.FirstName, employees.LastName FROM employees')
    .result();
  
// Joins the row set produced by a SQL SELECT with the row set produced by a
// SPARQL SELECT and then groups, orders, and limits the result:
const op = require('/MarkLogic/optic');
const topTweeters =
  op.fromSQL('SELECT customerId, customerName FROM customers WHERE ...', 'customers')
    .joinInner(
      op.fromSPARQL('SELECT ?customerId ?tweetId WHERE { ... }', 'tweets'),
      op.on(
        op.viewCol('customers', 'customerId'),
        op.viewCol('tweets',    'customerId')
        ))
    .groupBy('customerName', op.count('tweetCount', 'tweetId'))
    .orderBy('tweetCount')
    .limit(1000)
    .map(row => {...})
    .result();