Java Reference
In-Depth Information
The result of this query is to return all columns from any row containing the
Last_Name "Corleone". The order in which the columns are returned is the order in
which they are stored in the database; the row order is arbitrary.
Comparison operators
In addition to the equality operator used in the preceding example, SQL supports a
full range of standard comparison operators, including special operators used to test
for the presence or absence of a NULL value in a column:
 
Equality (=)
 
Inequality (<>)
 
Greater Than (>) and Greater Than or Equal To (>=)
 
Less Than (<) and Less Than or Equal To (<=)
 
IS NULL
 
IS NOT NULL
Comparison operations can be combined using the basic logical operators: AND, OR
and NOT.
Another way of combining operations is to nest subqueries. The syntax for nesting
subqueries uses parentheses to indicate nesting levels as shown below:
SELECT *
FROM Tables
WHERE
(SUBQUERY
(SUBQUERY
(SUBQUERY)));
Sorting the results of a query
A common requirement when retrieving data from an RDBMS by using the SELECT
statement is to sort the results of the query in alphabetical or numeric order on one or
more of the columns. Sorting result is done using the ORDER BY clause in a
statement like this:
SELECT First_Name, Last_Name, City, State
FROM CUSTOMERS
WHERE Last_Name = 'Corleone'
ORDER BY First_Name;
Joining tables
Search WWH ::




Custom Search