Skip to main content

Query Type

In this section, we deal with Query object in CRUD parameters, As you filter data in your sql queries, you can do this in OpenSql.

Query object :

keytyperequireddescription
getstring, string[]trueList of columns Or Single Column Or Function Helper
fromstring, string[]trueList of tables Or Single Table
whereWherefalseIn where object we have Map of columns with function helper for filter data
whereNotWherefalseOpposite of Where object
dataany[], JSONObjectfalseUsed to insert or update data
unionUnionObject[]falseUsed to combine the result-set of two or more SELECT statements
optionOptionfalseManage option query like: limit, order, group or sort data with asc and desc.
joinFnResult, FnResult[]falseA JOIN clause is used to combine rows from two or more tables, based on a related column between them.

Where object :

The use of the where key is only limited to find, update and remove operations. In fact, it is a filter on the data output. When you want to perform an operation on a specific range of data, you use this key in your queries.

keytyperequireddescription
columnNameanytrue...

UnionObject object :

The UNION operator is used to combine the result-set of two or more SELECT statements.

  • Every SELECT statement within UNION must have the same number of columns
  • The columns must also have similar data types
  • The columns in every SELECT statement must also be in the same order
keytyperequireddescription
valueQuerytrueUsed in Union Function Helper
typestringtrueType of Union Function Helper

Option object :

Glide option is a set of well-known keys such as group by, order by, having, limit and offset

keytyperequireddescription
columnNamestringfalseUsed to manage order from specific column. For example : DESC Or ASC
$groupstring, string[]falseGroups rows that have the same values into summary rows.
$havingFnResult, FnResult[]falseThe HAVING clause was added to SQL because the WHERE keyword cannot be used with aggregate functions.
$orderstring, string[]falseUsed to sort the result-set in ascending or descending order.
$limitnumber, number[]falseLimited number of records.
$offsetnumberfalseUsed with the ORDER BY clause with a value greater than or equal to zero.

FnResult object :

The output of all function helpers is of FnResult type. OpenSql does not know which type of join and which type of comparison operator is used in the written query, so you have to specify it.

tip

By default, the relation type is AND and the comparison operator is =.

keytyperequireddescription
valuestring, number, string[], number[], JSONObject, QCheckValueInObjecttrueValue of Function Helper
typestringtrueType of Function Helper
conjunctionTypestringfalseAND , OR
comparisonOperatorstringfalse= , >= , <= , ...

QCheckValueInObject object :

Used When you need query something like this :

SELECT *
FROM Customers
WHERE NOT Country = 'Germany'
AND NOT Country = 'USA';
keytyperequired
valuestring, numbertrue
haveNotbooleanfalse