-
Notifications
You must be signed in to change notification settings - Fork 7
jSQLWhereClause class
For query types that have a where clause ("DELETE", "SELECT", and "UPDATE"), this method is accessed via the query's where()
method. This is used to filter and sort results in a "SELECT" query or the results to be edited or delete with "DELETE" and "UPDATE" queries.
Set a column to add a filter to.
- column: The column to be used in the filter.
- The
jSQLWhereClause
object.
var allSusans =
jSQL.select('*')
.from('Users')
.where('Name')
.equals('Susan')
.execute()
.fetchAll();
Filter results to ones where the filtered column matches the given value
- value: The value to be used in the filter.
- The
jSQLWhereClause
object.
var OldUsers =
jSQL.select(['Name', 'Age'])
.from('Users')
.where('Age')
.equals(37)
.execute()
.fetchAll();
For use with "LIKE" modifiers which are used with a prepared query.
- The
jSQLWhereClause
object.
var PatrioticUsers =
jSQL.select(['Name', 'Age'])
.from('Users')
.where('Name')
.preparedLike()
.execute(['%usa%'])
.fetchAll();
Filter results to ones where the filtered column does not match the given value
- value: The value to be used in the filter.
- The
jSQLWhereClause
object.
var EveryoneButSusan =
jSQL.select(['Name', 'Age'])
.from('Users')
.where('Name')
.doesNotEqual('Susan')
.execute()
.fetchAll();
Filter results to ones where the filtered column is less than the given value
- value: The value to be used in the filter.
- The
jSQLWhereClause
object.
var hipsters =
jSQL.select(['Name'])
.from('Users')
.where('Age')
.lessThan(23)
.execute()
.fetchAll();
Filter results to ones where the filtered column contains the given substring.
- value: The value to be used in the filter.
- The
jSQLWhereClause
object.
var UsersLikeBob =
jSQL.select(['Name'])
.from('Users')
.where('Name')
.contains('bob')
.execute()
.fetchAll();
Filter results to ones where the filtered column ends with the given substring.
- value: The value to be used in the filter.
- The
jSQLWhereClause
object.
var nameEndsWithB =
jSQL.select(['Name'])
.from('Users')
.where('Name')
.endsWith('b')
.execute()
.fetchAll();
Filter results to ones where the filtered column begins with the given substring.
- value: The value to be used in the filter.
- The
jSQLWhereClause
object.
var nameBeginsWithB =
jSQL.select(['Name'])
.from('Users')
.where('Name')
.beginsWith('b')
.execute()
.fetchAll();
Begin an additional condition. Results must match both this condition and the preceeding one.
- column: The column to be used in the filter.
- The
jSQLWhereClause
object.
var nameBeginsAndEndsWithB =
jSQL.select(['Name'])
.from('Users')
.where('Name')
.beginsWith('b')
.and('Name')
.endsWith('b')
.execute()
.fetchAll();
Begin an additional condition. Results must match either this condition or the preceeding one.
- column: The column to be used in the filter.
- The
jSQLWhereClause
object.
var nameBeginsOrEndsWithB =
jSQL.select(['Name'])
.from('Users')
.where('Name')
.beginsWith('b')
.or('Name')
.endsWith('b')
.execute()
.fetchAll();
Limit the rows returned, deleted, or updated.
- limit: The number of rows to limit to.
- offset: The index at which to begin the result set.
- The
jSQLWhereClause
object.
var first3Users =
jSQL.select('Name')
.from('Users')
.limit(3)
.execute()
.fetchAll();
Sort the result set. Only useful for "SELECT" queries.
- column: The column or columns to order results by
- The
jSQLWhereClause
object.
var first3Users =
jSQL.select('Name')
.from('Users')
.limit(3)
.orderBy('Name')
.asc()
.execute()
.fetchAll();
Sort the result set ASCENDING. Only useful for "SELECT" queries.
- The
jSQLWhereClause
object.
var first3Users =
jSQL.select('*')
.from('Users')
.limit(3)
.orderBy('Name')
.asc()
.execute()
.fetchAll();
Sort the result set DESCENDING. Only useful for "SELECT" queries.
- The
jSQLWhereClause
object.
var first3Users =
jSQL.select('*')
.from('Users')
.limit(3)
.orderBy('Name')
.desc()
.execute()
.fetchAll();
Builds the result set based on conditions and prepared values provided and then executes the query's execute
method and returns the query itself rather than the query's where clause.
- The
jSQLQuery
object.
var allUsers =
jSQL.select('*')
.from('Users')
.execute()
.fetchAll();
jSQLTable.name
jSQLTable.columns
jSQLTable.data
jSQLTable.colmap
jSQLTable.renameColumn
jSQLTable.addColumn
jSQLTable.loadData
jSQLTable.insertRow
jSQLQuery.ifNotExists
jSQLQuery.ignore
jSQLQuery.execute
jSQLQuery.fetch
jSQLQuery.fetchAll
jSQLQuery.values
jSQLQuery.set
jSQLQuery.where
jSQLQuery.from
jSQLQuery.limit
jSQLQuery.orderBy
jSQLQuery.asc
jSQLQuery.desc
jSQLQuery.distinct
jSQLWhereClause.where
jSQLWhereClause.equals
jSQLWhereClause.preparedLike
jSQLWhereClause.doesNotEqual
jSQLWhereClause.lessThan
jSQLWhereClause.contains
jSQLWhereClause.endsWith
jSQLWhereClause.beginsWith
jSQLWhereClause.and
jSQLWhereClause.or
jSQLWhereClause.limit
jSQLWhereClause.orderBy
jSQLWhereClause.asc
jSQLWhereClause.desc
jSQLWhereClause.execute