By: Ivan Lim Emailed: 1745 times Printed: 2434 times
SQL is a language designed to be used with relational databases. There is a set of basic SQL commands that is considered standard and is used by all RDBMSs. For example, all RDBMSs use the SELECT statement.
A SELECT statement, also called a query, is used to get information from a table. It specifies one or more column headings, one or more tables from which to select, and some criteria for selection. The RDBMS returns rows of the column entries that satisfy the stated requirements. A SELECT statement such as the following will fetch the first and last names of employees who have company cars:
SELECT First_Name, Last_Name FROM Employees WHERE Car_Number IS NOT NULL
The result set (the set of rows that satisfy the requirement of not having null in the Car_Number column) follows. The first name and last name are printed for each row that satisfies the requirement because the SELECT statement (the first line) specifies the columns First_Name and Last_Name. The FROM clause (the second line) gives the table from which the columns will be selected.
FIRST_NAME LAST_NAME ---------- ----------- Axel Washington Florence Wojokowski
The following code produces a result set that includes the whole table
because it asks for all of the columns in the table Employees with no
WHERE clause). Note that
* means "SELECT all columns."
SELECT * FROM Employees
Be the first one to add a comment
Most Viewed Articles (in JDBC )
Most Emailed Articles (in JDBC)