Representing the Results of a Query
Go Up to Specifying What Data to Display
Using a query is the most general way to specify a set of records. Queries are simply commands written in SQL. You can use either TSQLDataSet or TSQLQuery to represent the result of a query.
When using TSQLDataSet, set the CommandType property to ctQuery and assign the text of the query statement to the CommandText property. When using TSQLQuery, assign the query to the SQL property instead. These properties work the same way for all general-purpose or query-type datasets. Specifying the Query discusses them in greater detail.
When you specify the query, it can include parameters, or variables, the values of which can be varied at design time or runtime. Parameters can replace data values that appear in the SQL statement. Using parameters in queries and supplying values for those parameters is discussed in Using Parameters in Queries.
SQL defines queries such as UPDATE queries that perform actions on the server but do not return records. Such queries are discussed in Executing Commands That Do Not Return Records.