4D v16SELECT |
||||||||||||||
|
4D v16
SELECT
SELECT
The SELECT command is used to retrieve data from one or more tables. SELECT *, SALES, TARGET FROM OFFICES ... is not allowed whereas: SELECT * FROM OFFICES ...is allowed. The FROM clause is used to specify one or more table_reference type arguments for the table(s) from which the data is to be retrieved. You can either pass a standard SQL name or a string. It is not possible to pass a query expression in the place of a table name. You may also pass the optional keyword AS to assign an alias to the column. If this keyword is passed, it must be followed by the alias name which can also be either an SQL name or string. Note: This command does not support 4D fields of the Object type. The optional WHERE clause sets conditions that the data must satisfy in order to be selected. This is done by passing a search_condition which is applied to the data retrieved by the FROM clause. The search_condition always returns a Boolean type value. The optional ORDER BY clause can be used to apply a sort_list criteria to the data selected. You can also add the ASC or DESC keyword to specify whether to sort in ascending or descending order. By default, ascending order is applied. The optional GROUP BY clause can be used to group identical data according to the sort_list criteria passed. Multiple group columns may be passed. This clause can be used to avoid redundancy or to compute an aggregate function (SUM, COUNT, MIN or MAX) that will be applied to these groups. You can also add the ASC or DESC keyword as with the ORDER BY clause. The optional HAVING clause can then be used to apply a search_condition to one of these groups. The HAVING clause may be passed without a GROUP BY clause. The optional LIMIT clause can be used to restrict the number of data returned by passing a 4d_language_reference variable or int_number. The optional OFFSET clause can be used to set a number (4d_language_reference variable or int_number) of data to be skipped before beginning to count for the LIMIT clause. The optional INTO clause can be used to indicate 4d_language_reference variables to which the data will be assigned. A SELECT command that specifies a FOR UPDATE clause attempts to obtain exclusive writing locks on all the selected records. If at least one record cannot be locked, then the whole command fails and an error is returned. If, however, all the selected records were locked, then they will remain locked until the current transaction is committed or rolled back. Suppose that you have a movie database with one table containing the movie titles, the year it was released and the tickets sold for that movie. C_LONGINT($MovieYear;$MinTicketsSold;$StartYear;$EndYear) Here is an example where a combination of search conditions are used:
Given a SALESREPS table where QUOTA is the expected sales amount for a sales representative and SALES is the actual amount of sales made. ARRAY REAL(arrMin_Values;0) Here is an example which finds all the actors born in a certain city: ARRAY TEXT(aActorName;0)
See also
4d_language_reference
|
PROPERTIES
Product: 4D
HISTORY
ARTICLE USAGE
4D SQL Reference ( 4D v16) |
||||||||||||