Please enable JavaScript to view this site.

Navigation: Advanced topics > Programming topics > Database API > Methods

Database API:Select()

Scroll Prev Next More

 

Retrieves data from the database.

Syntax

DB_Select(table, values)
' or
DB_Select(table, where)

Arguments

table

the table from which the data is selected.

values

an array with values that define the condition of the Select query.

where

the condition for the Select query.

Return value

An array with the result of the Select query.

Example 1

Retrieve all data from the Cars table where the make is Toyota and the model is RAV4.

 

Dim data,rs,record
Set data = CreateDictionary()
data("make") = "Toyota"
data("model") = "RAV4"
set rs = DB_Select("Cars",data)
do while bValue(doAssignmentByRef(record,rs.fetchAssoc()))
  ResponseWrite record("id")
  ResponseWrite record("Make")
loop

Example 2

Retrieve all data from the Cars table where the price is less than 20,000.

 

Dim rs,record
set rs = DB_Select("Cars","price<20000")
do while bValue(doAssignmentByRef(record,rs.fetchAssoc()))
  ResponseWrite ArrayElement(record,"id")
  ResponseWrite ArrayElement(record,"Make")
loop

See also:

QueryResult object: fetchAssoc()

Database API: Exec()

Database API: Query()

Database API: Insert()

Database API: Update()

Database API: Delete()

Database API: PrepareSQL()

QueryResult object: fetchNumeric()

QueryResult object: value()

Using SQL variables

About Database API