+1-617-874-1011 (US)

  +44-117-230-1145 (UK)

SQL Queries And Updates

SQL code is written in the form of a query statement and then executed against a database. All SQL queries perform some type of data operation such as selecting data, inserting/updating data, or creating data objects such as SQL databases and SQL tables. Each query statement begins with a clause such as SELECT, UPDATE, CREATE or DELETE.

The most typical procedure within SQL is the query, that is carried out using the declarative SELECT statement. SELECT retrieves data from a number of tables, or expressions. Standard SELECT statements have no persistent effects on the database. Some non-standard implementations of SELECT can have persistent effects, such as the SELECT INTO Syntax that exists in some databases.

Queries allow the person to explain preferred data, leaving the database management system (DBMS) responsible for planning, optimizing and performing the physical operations necessary to produce that result as it chooses.

A query consists a list of columns to be included in the final result immediately following the SELECT keyword. An asterisk ("*") can also be used to specify that the query should return all columns of the queried tables. SELECT is the most complex statement in SQL, with optional keywords as well as clauses including:

  • The FROM clause which signifies the table(s) from which data is to be retrieved. The FROM clause can include optional JOIN subclauses to specify the rules for joining tables.
  • The WHERE clause includes a comparison predicate, which restricts the rows returned by the query. The WHERE clause eliminates all rows from the result set for which the comparison predicate does not evaluate to True.
  • The GROUP BY Clause is used in order to project rows having common values into a smaller set of rows. GROUP BY is usually utilized along with SQL aggregation functions or to eliminate duplicate rows from a result set. The WHERE clause is applied before the GROUP BY clause.
  • The HAVING clause includes a predicate used to filter rows resulting from the GROUP BY clause. Because it acts on the results of the GROUP BY clause, aggregation functions can be used in the HAVING clause predicate.
  • The ORDER BY Clause identifies which columns are used to sort the resulting data and in which direction they should be sorted (options are ascending or descending). Without an ORDER BY clause, the order of rows returned by an SQL query is undefined.
Homework Help with SQL Queries And Updates