Child pages
  • QBSelect

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Divcache
Div
iddescription
HTML Table
id
classservoy sSummary
Colgroup Tag
Col
width80px
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Property Summary
Table Row (tr)
Table Cell (td)
QBLogicalCondition
Table Cell (td)and
styleindexdisplay:none

DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY (EXCEPT INSIDE THE DIV BELOW WITH ID=DESCRIPTION), UNLESS YOU KNOW WHAT YOU'RE DOING.
THE STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO AUTO UPDATE THE CONTENT THROUGH THE DOC GENERATOR.

true
refresh100d
showRefreshtrue
iddoc
titleRefresh page
showDatetrue
retryEnable
idclass

servoy sReturnTypes2100%height: 30px;2Supported ClientssWordListSmartClientsWordListWebClientsWordListNGClient

servoy sSummary12%30%58%height: 30px;3Property SummaryCreate an AND-condition to add conditions to.

Table Row (tr)
Table Cell (td)
QBColumns
Table Cell (td)
columns
Get columns from query
Table Row (tr)
Table Cell (td)
QBFunctions
Table Cell (td)functions
Table Row (tr)
Table Cell (td)
QBGroupBy
Table Cell (td)groupBy
Get all the columns of the datasource that can be used for this query (select or where clause)Get the functions clause from a query, used for functions that are not tied to a column.Get the group by clause from a query Table Row (tr)
Table Cell (td)
QBLogicalCondition
Table Cell (td)having
Table Cell (td)joins
Get the having-part of the query, used to add conditions. Table Row (tr)
Table Cell (td)
QBJoins
Table Cell (td)or
Get the joins clause of this table based clause. Table Row (tr)
Table Cell (td)
QBLogicalCondition
Create an OR-condition to add conditions to. Table Row (tr)
Table Cell (td)
QBParameters
Table Cell (td)params
Get the named parameters from a query. Table Row (tr)
Table Cell (td)
QBTableClause
Table Cell (td)parent
result
Get query builder parent table clause, this may be a query or a join clause. Table Row (tr)
Table Cell (td)
QBResult
Table Cell (td) Table Row (tr)
Table Cell (td)
QBSelect
Table Cell (td)root
Get the result part of the query, used to add result columns or values. Table Cell (td)sort
Get query builder parent. Table Row (tr)
Table Cell (td)
QBSorts
Get the sorting part of the query. Table Row (tr)
Table Cell (td)
QBWhereCondition
Table Cell (td)where
Get the where-part of the query, used to add conditions. HTML Table

Colgroup Tag
Col
width80px
Col
Table Head (thead) Table Row (tr)styleservoy sSummary Table Row (tr)
Table Cell (td)
QBSelect
Table Cell (td)clearHaving()
12%30%58%height: 30px;
Table Head (th)
colspan2
Method Summary
3Methods SummaryClear the having-part of the query. Table Row (tr)
Table Cell (td)
QBCondition
Table Cell (td)exists()
Table Cell (td)getColumn(name)
Get an exists-condition from a subquery Table Row (tr)
Table Cell (td)
QBColumn
Get a column from the table. Table Row (tr)
Table Cell (td)
QBColumn
Table Cell (td)getColumn(columnTableAlias, name)
Table Row (tr)
Table Cell (td)
QBParameter
Table Cell (td)getParameter()
Get a column from the table with given alias.Returns the datasource for this.Get or create a parameter for the query, this used to parameterize queries. Table Row (tr)
Table Cell (td)
QBCondition
Table Cell (td)not(cond)
Table Cell (td)
QBCondition
Table Cell (td)not(cond)
.Returns the table alias for this.Create an negated condition. Table Row (tr)Create an negated condition.table

id

propertyclass Colgroup Tag Colcolspanservoy sDetail2width100%

Col
Table Head (thead) Table Row (tr)styleheight:30px; Table Head (th)colspan2Property Details Table Body (tbody)ididand Table Row (tr)nametd

and

Table Row (tr)id

des Table Cell (td) DivclasssIndentCreate an AND-condition to add conditions to. Table Row (tr)idtdret

Returns

divsIndentclients

classtd

Supported Clients

sIndent
QBLogicalCondition Table Row (tr)
idsam
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idcolumns
Table Row (tr)
idname
Table Cell (td)

columns

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Get columns from query
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
QBColumns
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
foundset.getQuery().columns
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idfunctions
Table Row (tr)
idname
Table Cell (td)

functions

Table Row (tr)
iddes
Table Cell (td) Div
classsIndent
SmartClient,WebClient,NGClientsam

Sample

Div
classsIndent
Code Block
languagejavascript
query.where.add(
	  query.or
	    .add(
	      query.and
		    .add(query.columns.flag.eq(1))
	    .add(query.columns.order_date.isNull)
		 )
	    .add(
	      query.and
	        .add(query.columns.flag.eq(2))
	        .add(query.column.order_date.gt(new Date()))
	     )
	);
Table Row (tr)idsIdentjavascriptlastDetailRow columnsname

columns

dessIndentGet all the columns of the datasource that can be used for this query (select or where clause)ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow 
functionsname

functions

dessIndentGet the functions clause from a query, used for functions that are not tied to a column.
tdret

Returns

divsIndentclients

classtd

Supported Clients

sIndent
QBFunctions Table Row (tr)
idsam
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgroupBy
Table Row (tr)
idname
Table Cell (td)

groupBy

Table Row (tr)
iddes
Table Cell (td) Div
classsIndent
SmartClient,WebClient,NGClientsam

Sample

Div
classsIndent
Code Block
languagejavascript
/** @type {QBSelect<db:/example_data/orders>} */
var query = databaseManager.createSelect('db:/example_data/orders') //$NON-NLS-1$
query.where.add(query.columns.shipname.upper.eq(query.functions.upper('servoy'))) //$NON-NLS-1$
foundset.loadRecords(query)
sIdentjavascriptlastDetailRow&nbsp;groupByname

groupBy

dessIndentGet the group by clause from a query
Table Row (tr)idtdret

Returns

divsIndentclients

classid

Supported Clients

sIndent
QBGroupBy Table Row (tr)SmartClient,WebClient,NGClientsam

Table Cell (td)

Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idhaving
Table Row (tr)
idname
Table Cell (td)

having

Table Row (tr)
iddes
Table Cell (td) Div
classsIndent

Sample

Div
classsIndent
Code Block
languagejavascript
/** @type {QBSelect<db:/example_data/orders>} */
var query = databaseManager.createSelect('db:/example_data/orders')
query.groupBy.addPk() // have to group by on pk when using having-conditions in (foundset) pk queries
.root.having.add(query.joins.orders_to_order_details.columns.quantity.count.eq(0))
foundset.loadRecords(query)
sIdentjavascriptlastDetailRow&nbsp;havingname

having

dessIndentGet the having-part of the query, used to add conditions.

Table Row (tr)id The conditions added here are AND-ed.tdret

Returns

divsIndentclients

classtd

Supported Clients

sIndent
QBLogicalCondition Table Row (tr)
idsam
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idjoins
Table Row (tr)
idname
Table Cell (td)

joins

Table Row (tr)
iddes
Table Cell (td) Div
classsIndent
SmartClient,WebClient,NGClientsam

Sample

Div
classsIndent
Code Block
languagejavascript
/** @type {QBSelect<db:/example_data/orders>} */
var query = databaseManager.createSelect('db:/example_data/orders')
query.groupBy.addPk() // have to group by on pk when using having-conditions in (foundset) pk queries
.root.having.add(query.joins.orders_to_order_details.columns.quantity.count.eq(0))
foundset.loadRecords(query)
sIdentjavascriptlastDetailRow&nbsp;joinsname

joins

dessIndentGet the joins clause of this table based clause.

Table Row (tr)id Joins added to this clause will be based on this table clauses table.tdret

Returns

divsIndentclients

classtd

Supported Clients

sIndent
QBJoins Table Row (tr)
idsam
SmartClient,WebClient,NGClientsam

Sample

Div
classsIndent
Code Block
languagejavascript
foundset.getQuery().joins
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idor
Table Row (tr)
idname
Table Cell (td)

or

Table Row (tr)
iddes
Table Cell (td) Div
classsIndent
Table Row (tr)idsIdentjavascriptlastDetailRow&nbsp;orname

or

dessIndentCreate an OR-condition to add conditions to.
tdret

Returns

divsIndentclients

classtd

Supported Clients

sIndent
QBLogicalCondition Table Row (tr)
idsam
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idparams
Table Row (tr)
idname
Table Cell (td)

params

Table Row (tr)
iddes
Table Cell (td) Div
classsIndent
SmartClient,WebClient,NGClientsam

Sample

Div
classsIndent
Code Block
languagejavascript
query.where.add(
	  query.or
	    .add(
	      query.and
		    .add(query.columns.flag.eq(1))
	    .add(query.columns.order_date.isNull)
		 )
	    .add(
	      query.and
	        .add(query.columns.flag.eq(2))
	        .add(query.column.order_date.gt(new Date()))
	     )
	);
sIdentjavascriptlastDetailRow&nbsp;paramsname

params

dessIndentGet the named parameters from a query.
Table Row (tr)idtdret

Returns

divsIndentclients

classid

Supported Clients

sIndent
QBParameters Table Row (tr)SmartClient,WebClient,NGClientsam

Table Cell (td)

Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idparent
Table Row (tr)
idname
Table Cell (td)

parent

Table Row (tr)
iddes
Table Cell (td) Div
classsIndent

Sample

Div
classsIndent
Code Block
languagejavascript
/** @type {QBSelect<db:/example_data/orders>} */
	var query = databaseManager.createSelect('db:/example_data/orders')
	query.where.add(query.columns.contact_id.eq(query.getParameter('mycontactid')))

	// load orders where contact_id = 100
	query.params['mycontactid'] = 100
	foundset.loadRecords(query)

	// load orders where contact_id = 200
	query.params['mycontactid'] = 200
	foundset.loadRecords(query)
Table Row (tr)idsIdentjavascriptlastDetailRow&nbsp;parentname

parent

dessIndentGet query builder parent table clause, this may be a query or a join clause.
tdret

Returns

divsIndentclients

classtd

Supported Clients

sIndent
QBTableClause Table Row (tr)
idsam
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idresult
Table Row (tr)
idname
Table Cell (td)

result

Table Row (tr)
iddes
Table Cell (td) Div
classsIndent
SmartClient,WebClient,NGClientsam

Sample

Div
classsIndent
Code Block
languagejavascript
/** @type {QBSelect<db:/example_data/person>} */
	var query = databaseManager.createSelect('db:/example_data/person')
	query.where.add(query.joins.person_to_parent.joins.person_to_parent.columns.name.eq('john'))
	foundset.loadRecords(query)
Table Row (tr)idsIdentjavascriptlastDetailRow&nbsp;resultname

result

dessIndentGet the result part of the query, used to add result columns or values.
tdret

Returns

divsIndentclients

classtd

Supported Clients

sIndent
QBResult Table Row (tr)
idsam
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idroot
Table Row (tr)
idname
Table Cell (td)

root

Table Row (tr)
iddes
Table Cell (td) Div
classsIndent
SmartClient,WebClient,NGClientsam

Sample

Div
classsIndent
Code Block
languagejavascript
query.result.add(query.columns.company_id).add(query.columns.customerid)
sIdentjavascriptlastDetailRow&nbsp;rootname

root

dessIndentGet query builder parent.
Table Row (tr)idret

Table Cell (td)

Returns

divsIndentclients

classtd

Supported Clients

sIndent
QBSelect Table Row (tr)
idsam
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idsort
Table Row (tr)
idname
Table Cell (td)

sort

Table Row (tr)
iddes
Table Cell (td) Div
classsIndent
SmartClient,WebClient,NGClientsam

Sample

Div
classsIndent
Code Block
languagejavascript
/** @type {QBSelect<db:/example_data/order_details>} */
	var subquery = databaseManager.createSelect('db:/example_data/order_details')

 /** @type {QBSelect<db:/example_data/orders>} */
	var query = databaseManager.createSelect('db:/example_data/orders')
	query.where.add(query
		.or
			.add(query.columns.order_id.not.isin([1, 2, 3]))

			.add(query.exists(
					subquery.where.add(subquery.columns.orderid.eq(query.columns.order_id)).root
			))
		)

	foundset.loadRecords(query)
Table Row (tr)idsIdentjavascriptlastDetailRow&nbsp;sortname

sort

dessIndentGet the sorting part of the query.
tdret

Returns

divsIndentclients

classtd

Supported Clients

sIndent
QBSorts Table Row (tr)
idsam
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idwhere
Table Row (tr)
idname
Table Cell (td)

where

Table Row (tr)
iddes
Table Cell (td) Div
classsIndent
SmartClient,WebClient,NGClientsam

Sample

Div
classsIndent
Code Block
languagejavascript
/** @type {QBSelect<db:/example_data/orders>} */
var query = databaseManager.createSelect('db:/example_data/orders')
query.sort
.add(query.joins.orders_to_order_details.columns.quantity.desc)
.add(query.columns.companyid)
foundset.loadRecords(query)
sIdentjavascriptlastDetailRow&nbsp;wherename

where

dessIndentGet the where-part of the query, used to add conditions.

Table Row (tr)id The conditions added here are AND-ed.tdret

Returns

divsIndentclients

classtd

Supported Clients

sIndent
QBWhereCondition Table Row (tr)
idsam
Colgroup Tag
Col
colspan2
width100%
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Method Details
Table Body (tbody)
idclearHaving
Table Row (tr)
idname
Table Cell (td)

clearHaving

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
QBSelect
Span
stylefont-weight: bold;
clearHaving
Span
()
Table Row (tr)
iddes
Table Cell (td) Div
classsIndent
SmartClient,WebClient,NGClientsam

Sample

Div
classsIndent
Code Block
languagejavascript
var query = foundset.getQuery()
query.where.add(query.columns.flag.eq(1))
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
HTML Table
idfunction
classservoy sDetail
sIdentjavascriptlastDetailRow&nbsp;

functionservoy sDetail2100%height:30px2Methods DetailsclearHavingname

clearHaving()

dessIndentClear the having-part of the query.
Table Row (tr)idrettd

Returns

divsIndentclients

classtd

Supported Clients

sIndent
QBSelect Table Row (tr)
idsam
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idexists
Table Row (tr)
idname
Table Cell (td)

exists

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
QBCondition
Span
stylefont-weight: bold;
exists
Span
()
Table Row (tr)
iddes
Table Cell (td) Div
classsIndent
SmartClient,WebClient,NGClientsam

Sample

Div
classsIndent
Code Block
languagejavascript
var q = foundset.getQuery()
q.where.add(q.columns.x.eq(100))
query.groupBy.clear.root.clearHaving()
foundset.loadRecords(q);
sIdentjavascriptlastDetailRow&nbsp;existsname

exists(query)

dessIndentGet an exists-condition from a subqueryprs

Table Row (tr)

idret
td

Parameters

sIndentquerythe sub query
ret

Returns

divsIndentclients

classid

Supported Clients

sIndent
QBCondition Table Row (tr)SmartClient,WebClient,NGClientsam

Table Cell (td)

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
QBColumn
Span
stylefont-weight: bold;
getColumn
Span
(name)
Table Row (tr)
iddes
Table Cell (td) Div
classsIndent

Sample

Div
classsIndent
Code Block
languagejavascript
foundset.query.where.add(query.exists(query2))
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetColumn-String
Table Row (tr)
idname
Table Cell (td)

getColumn

sIdentjavascriptlastDetailRow&nbsp;getColumnname

getColumn(name)

dessIndentGet a column from the table.
Table Row (tr)idtdprs

Parameters

Divclass

sIndent{String} name - the name of column to get Table Row (tr)idret

Table Cell (td)

Returns

divsIndentclients

classtd

Supported Clients

sIndent
QBColumn Table Row (tr)
idsam
Span
stylemargin-right: 5px;
QBColumn
Span
stylefont-weight: bold;
getColumn
SpanSmartClient,WebClient,NGClientsam

Sample

Div
classsIndent
Code Block
languagejavascript
foundset.getQuery().getColumn('orderid')
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetColumn-String_String
Table Row (tr)
idname
Table Cell (td)

getColumn

Table Row (tr)
idsig
Table Cell (td)sIdentjavascriptlastDetailRow&nbsp;getColumnname

getColumn(columnTableAlias, name)

Table Row (tr)idclass

des Table Cell (td) DivsIndentGet a column from the table with given alias.
Table Row (tr)id The alias may be of the main table or any level deep joined table.tdprs

Parameters

Divclass

sIndent{String} columnTableAlias - the alias for the table
{String} name - the name of column to get Table Row (tr)idtdret

Returns

divsIndentclients

classtd

Supported Clients

sIndent
QBColumn Table Row (tr)
idsam
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetParameter
Table Row (tr)
idname
Table Cell (td)

getParameter

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
QBParameter
Span
stylefont-weight: bold;
getParameter
Span
()
Table Row (tr)
iddes
Table Cell (td) Div
classsIndent
SmartClient,WebClient,NGClientsam

Sample

Div
classsIndent
Code Block
languagejavascript
foundset.getQuery().getColumn('orderid', 'opk')
sIdentjavascriptlastDetailRow&nbsp;getDataSourcename

getDataSource()

dessIndentReturns the datasource for this.ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow&nbsp;
getParametername

getParameter(name)

dessIndentGet or create a parameter for the query, this used to parameterize queries.prs

Table Row (tr)

idret
td

Parameters

sIndentnamethe name of the parameter
ret

Returns

divsIndentclients

classtd

Supported Clients

sIndent
QBParameter Table Row (tr)
idsam
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idnot-QBCondition
Table Row (tr)
idname
Table Cell (td)

not

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
QBCondition
Span
stylefont-weight: bold;
not
Span
(cond)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Create an negated condition.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{QBCondition} cond - the condition to negate
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
QBCondition
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
foundset.query.where.add(query.not(query.columns.flag.eq(1)))
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idnot-QBLogicalCondition
Table Row (tr)
idname
Table Cell (td)

not

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
QBCondition
Span
stylefont-weight: bold;
not
Span
(cond)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Create an negated condition.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{QBLogicalCondition} cond - the logical condition to negate
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
QBCondition
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
foundset.query.where.add(query.not(query.columns.flag.eq(1)))
Table Row (tr)
classlastDetailRow
Table Cell (td) SmartClient,WebClient,NGClientsam

Sample

Div
classsIndent
Code Block
languagejavascript
/** @type {QBSelect<db:/example_data/orders>} */
	var query = databaseManager.createSelect('db:/example_data/orders')
	query.where.add(query.columns.contact_id.eq(query.getParameter('mycontactid')))

	// load orders where contact_id = 100
	query.params['mycontactid'] = 100
	foundset.loadRecords(query)

	// load orders where contact_id = 200
	query.params['mycontactid'] = 200
	foundset.loadRecords(query)
sIdentjavascriptlastDetailRow&nbsp;getTableAliasname

getTableAlias()

dessIndentReturns the table alias for this.ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow&nbsp;
notname

not(cond)

dessIndentCreate an negated condition.prs

Parameters

sIndentcondthe condition to negate
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow&nbsp;
notname

not(cond)

dessIndentCreate an negated condition.prs

Parameters

sIndentcondthe logical condition to negate
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow&nbsp;