1994.5.17
by Stewart Smith
remove \r at end of line as they cause kitten injuries. |
1 |
Executing Queries
|
1900.2.5
by Stewart Smith
fix docs warning: underline/overline too short for queries.rst |
2 |
=================
|
1878.5.4
by Brian Aker
Update documentation. |
3 |
|
1945.3.4
by Marisa Plumb
SQL edits and rewrites |
4 |
Queries retrieve data from a database based on specific criteria. They |
5 |
are performed with the declarative SELECT statement, which has no |
|
6 |
persistent effects on the database. SELECT simply retrieves data from |
|
7 |
one or more tables, or expressions. |
|
8 |
||
9 |
A query includes a list of columns to be included in a result set; an example of this would be: ::
|
|
10 |
||
1994.4.3
by Marisa Plumb
few updates and modifications to admin commands |
11 |
SELECT * FROM table_name;
|
12 |
||
1994.4.21
by Marisa Plumb
adding tungsten doc |
13 |
SELECT * FROM is an example of using SELECT with clauses. The select clause specifies the columns you want to retrieve. The from clause specifies the tables to search. |
1994.4.3
by Marisa Plumb
few updates and modifications to admin commands |
14 |
|
15 |
Keywords and clauses include: |
|
1945.3.4
by Marisa Plumb
SQL edits and rewrites |
16 |
|
1994.4.16
by Marisa Plumb
new function and clause files, some placeholders for right now |
17 |
.. toctree:: |
18 |
:maxdepth: 2
|
|
19 |
||
20 |
where |
|
21 |
distinct |
|
22 |
groupby |
|
23 |
having |
|
24 |
orderby |
|
25 |
join |
|
1994.4.3
by Marisa Plumb
few updates and modifications to admin commands |
26 |
|
27 |
For example, ::
|
|
28 |
||
29 |
SELECT first_column_name, second_column_name
|
|
30 |
FROM table_name
|
|
31 |
WHERE first_column_name > 1000;
|
|
32 |
||
1994.4.16
by Marisa Plumb
new function and clause files, some placeholders for right now |
33 |
The column names that follow the SELECT keyword determine the columns that will be returned in the results. You can select as many column names that you'd like, or you can use a * to select all columns (as shown in the first example above). The order in which they are specified will be reflected in your query results. |
34 |
||
35 |
The table name that follows the keyword FROM specifies the table that will be queried to retrieve the desired results. |
|
36 |
||
1994.5.17
by Stewart Smith
remove \r at end of line as they cause kitten injuries. |
37 |
The WHERE clause (optional) specifies the data values or rows to be returned or displayed, based on the criteria described after the keyword WHERE. |