SELECTing data
As seen in the previous example, a basic SQL query block syntax is something like:
We will add more complexity, but for now this is the basic setup. Consider the following table, containing these columns:
This then returns all of the data in the table:
As an aside, as mentioned in the topic designing databases, as instrument_id is a surrogate key it is like that the full table would also include a field for a real-world identifier such as a serial number. In addition, as in this case we only query one table and our scope is restricted to that, there is no room for ambiguity in column names and we could have omitted the aliased table name and qualified column names; it is often good practice to always include them, however, particularly as it's common for a query to become the base of a larger query which may include more tables.
If we are requesting the data from all of the columns, we could have replaced the list with the wildcard "*", but the output from such a query would not be stable long-term if more columns were added:
Often, getting all of the data is not what we want, but there are ways of tailoring and manipulating the returned data set using WHERE, ORDER BY, GROUP BY/HAVING and other methods.