Monday 18 June 2012

Lesson 4: Retrieving All Data in SQL


Select statements are used to retrieve data from  SQL tables. The Select statement illustrated below retrieves all of the columns and rows  from the named table.


Syntax:
Select *
from tablename;


Explanation:
  • A Select statement is a SQL statement that begins with the word "select."
  • Select statements are used to retrieve data from SQL tables.
  • An asterisk after the word "select" means retrieve all fields (columns).
  • The name of the table from which you are retrieving data is specified in the From clause.
  • Use a semicolon to signify the end of a SQL statement.
Example:Retrieve all of the data from the TrnVendor table.
  1. In the SQL text box, type:
Select *
from TrnVendor; 
  1. Execute the command by clicking on First, the Run button located to the right of the SQL text box. The results will display on the screen.
  2. Use the horizontal scroll bar to move across the screen. The fields in the Vendor table will display alphabetically. Use the vertical scroll bar to move up and down the screen.
  3. Click on Stop to return to the original screen.
Results:
 
VendIdNameAdd1CityStateCurrBalExpAcct
TV001Wet Off Towels66 Keep Dry WayToledoOH1.31300E+0017230
TV002The Games All Here85 Olympic DriveWarrenNY4.53170E+0024110
TV003BedMakers Linen97 Comfort ZoneChicagoIL5.00000E+0024120
TV004Bed Room Furniture, Inc.4 Hide A WayMercerNJ3.21700E+0026080
TV005Ray Block90 Sunscreen Blvd.DetroitMI1.00123E+0037230

No comments:

Post a Comment