Professional SQL Editor For A Fraction Of The Price

Selecting data from a table

A result set is a set of data selected from a database and stored in a result table. Result tables consist of rows and columns with criteria depending on the query executed.

Basic SQL Select Syntax

A very basic query will select all rows containing all specified columns from the database table.

select column_one, column_two, column_three, column_four
from table_name
SQL Select Syntax With Conditions

To limit the results of a select query the where clause can be used. All rows will be returned that satisfy the conditions of the where clause used.

select column_one, column_two, column_three, column_four
from table_name
where column_one = 'condition' or column_two > 'condition' and column_three < 'condition'
Demo Table

Here is a very simple database table which holds information about people. The table is called Person. The table has only four rows and four columns to keep things simple in the examples.

first_name last_name city state
Nic Raboy Merced California
Jane Doe Newark New York
John Lee Las Vegas Nevada
Maria Campos Modesto California
Example SQL Queries

The following SQL statement will select all rows of only first_name and city columns from the Person table.

select first_name, city
from Person

The following SQL statement will select all rows of only first_name and last_name columns from the Person table. However, rows will only appear in the dataset if the person's state is California.

select first_name, last_name
from Person
where state = 'California'