6.6: Introduction to Structure Query Language (SQL)
- Page ID
- 93665
SQL is the universal query language of relational database management systems (DBMS) that is almost always behind user-friendly GUIs. In this section, we will briefly talk about SQL queries. We will visit SQL in more detail in later chapters.
SQL statements can also include a SQL comment, which is a block of text used to document the SQL statement but not executed as part of the statement. SQL comments are enclosed in the symbols /* and */, and any text between these symbols is ignored when the SQL statement is executed. Here is an example:
/* SQL-Query-Ch02 */
The fundamental statement of SQL query can apply to Microsoft Access, SQL Server, Oracle Database, and MySQL. The basic form of SQL queries uses SQL SELECT – FROM – WHERE framework. Here are some basic specifications:
- The SQL SELECT statement specifies which columns are to be listed in the query results.
- The SQL FROM statement specifies which tables are to be listed in the query results.
- The SQL WHERE statement specifies which rows are to be listed in the query results.
Reading Specified Columns from Single Table – to obtain values from the SKU_Data table, we write a SQL SELECT statement that contains all of the column names in the table:
/* SQL-Query-Ch_02 */
Below is a SQL queries from a single table, which obtains just the value of the Department and Buyer columns of the SKU_Data table:
The Catalog_SKU_2019 table shows DateOnWebSite. To see these items, we use the follow query: /* SQL-Query-Ch_02 */