Friday, 26 August 2016

Get All Data


SQL Select Statement


It's time to run your first SQL query! As you remember, the data in a database are stored in tables.

You can see all data in the user table with this query:

SELECT * FROM user;

SELECT tells your database that you want to select data. FROM user tells the database to select data from the table user.

Finally, the asterisk (*) tells the database that you want to see all columns in this table.

Remember to always end your SQL command with a semicolon (;). A semicolon is like a dot at the end of the sentence. It tells the database that you're done with your command.



VIN
BRAND
MODEL
PRICE
PRODUCTION_YEAR
LJCPCBLCX14500264
Ford
Focus
8000.00
2005
WPOZZZ79ZTS372128
Ford
Fusion
12500.00
2008
JF1BR93D7BG498281
Toyota
Avensis
11300.00
1999
KLATF08Y1VB363636
Volkswagen
Golf
3270.00
1992
1M8GDM9AXKP042788
Volkswagen
Golf
13000.00
2010
1HGCM82633A004352
Volkswagen
Jetta
6420.00
2003
1G1YZ23J9P5800003
Fiat
Punto
5700.00
1999
GS723HDSAK2399002
Opel
Corsa
null
2007


 

As you can see, the table car has 5 columns:
  1. vin (short for vehicle identification number),
  2. brand,
  3. model,
  4. price and
  5. production_year.
The names of the columns are at the top of the result.
There are 8 cars in our table: two Ford cars, one Toyota, three Volkswagens, one Fiat and one Opel. You can see that the price of a Toyota is 11 300 and the prices for Fords are 8 000 and 12 500. Note that the price for Opel is not specified - we'll explain that later.










No comments:

Post a Comment