Database Reference
In-Depth Information
6 transmission string
7 fuel string
8 consumption1 string
9 consumption2 string
10 consumption3 string
11 consumption4 string
12 avefuel string
13 co2 string
The SELECT Statement
The SELECT keyword plucks data from a database table. For example, I can select data from the “consumption” table of
the fuel database. The asterisk ( *) indicates that all column data within the table should be selected. (As this example
contains a lot of data, I provide only a couple of rows of the output to give an idea of the results):
SELECT * from fuel.consumption ;
1 1995 ACURA INTEGRA SUBCOMPACT 1.8 4 A4 X 10.2
7 28 1760 202
2 1995 ACURA INTEGRA SUBCOMPACT 1.8 4 M5 X 9.6
7 29 40 1680 193
If I need only a portion of the data, I can replace the asterisk ( *) with specific columns names, such as “myear”
and “manufacturer”:
SELECT myear, manufacturer from fuel.consumption ;
1 1995 ACURA
2 1995 ACURA
The WHERE Clause
The WHERE clause is used with SELECT , INSERT , and DELETE statements to filter the results of a request. Here are some
examples of SELECT statements with their WHERE clauses serving as filters for obtaining data by manufacturer or year:
SELECT * from fuel.consumption WHERE manufacturer = 'ACURA' ;
SELECT * from fuel.consumption WHERE myear = '1995' AND manufacturer = 'AUDI' ;
SELECT * from fuel.consumption WHERE myear = '1995' OR manufacturer = 'AUDI' ;
The first statement limits the selected rows to those where “manufacturer” is equal to ACURA. The second limits
the selected rows to where “myear” is 1995 and the “manufacturer” is AUDI. The final example limits the selected
rows to where “myear” is 1995 or the “manufacturer” is AUDI.
 
Search WWH ::




Custom Search