Simple Queries
The @@SELECT@@ statement performs queries on a relational database and is the most commonly used SQL command. The result is stored in a derived table.
Extract All Tuples
All Tuples and All Attributes
Extract all data in the table which includes all rows and columns.
- SELECT * FROM table-name;
All Tuples with a Subset of Attributes
- SELECT attr1, attr2, ..., attrN FROM table-name;
Extract a Subset of Tuples
All Attributes
Extract a subset of tuples from the table where each tuple includes all of the attributes.
- SELECT * FROM table-name WHERE condition;
Subset of Attributes
- SELECT attr1, attr2, ..., attrN FROM table-name WHERE condition;
Sorting the Results
- SELECT * FROM table-name WHERE condition ORDER BY attr-list;