SQL Select

SQL select statements are used to retrieve data from SQL databases. Take our free online SQL tutorial and learn SQL. Among the many commands we teach you are the SQL commands used to select and order data contained in a SQL database.

Table of Contents

Retrieving All Data

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:
 
VendId Name Add1 City State CurrBal ExpAcct
TV001 Wet Off Towels 66 Keep Dry Way Toledo OH 1.31300E+001 7230
TV002 The Games All Here 85 Olympic Drive Warren NY 4.53170E+002 4110
TV003 BedMakers Linen 97 Comfort Zone Chicago IL 5.00000E+002 4120
TV004 Bed Room Furniture, Inc. 4 Hide A Way Mercer NJ 3.21700E+002 6080
TV005 Ray Block 90 Sunscreen Blvd. Detroit MI 1.00123E+003 7230
TV006 Mosquito No Bite 99 Repellent Way Park Ridge NJ 9.67240E+002 6510
TV007 Spot Out 77 Sunset Strip Detroit MI 1.60654E+003 6500
TV008 Big Tree Landscaping 44 Broad Street Monroe NY 3.42980E+002 4110
TV009 Hit the Deck 42 Deck Lane Toledo OH 2.34500E+001 4030
TV010 The Soda Factory 101 Fizz Up Blvd. Orlando FL 0.00000E+000 4110
TV011 The Freelance 1 Trim Way Mercer NJ -1.09230E+002 7230
TV012 Paper People 80 Pulp Fiction Drive New York NY 6.17000E+002 6080
TV013 Softer Software 44 User Friendly Dr. Monroe NY 9.87367E+003 7230
TV014 Counter Productive 26 Shelf Street Toledo OH 4.28900E+001 6510
TV015 No Waste Disposal 5819 Street Road Park Ridge NY 1.72098E+003 6500
TV016 Music Maker 54 Note Street Chicago IL 4.10914E+003 4110
TV017 Food Four 67 Janice Blvd. Freeport MA 6.42980E+002 4110
TV018 Computer Bytes 10 Electric Dog Street Youngstown WA 3.45090E+002 7230
TV019 Bayshore Consulting 6479 Bay Drive Bayshore CA 4.98050E+002 4110
TV020 BayCon Group 1 Tutorial Lane Burlington NJ 5.10000E+001 4120
TV021 Cooperative Operatives 101 Systems Go Dallas TX 2.00000E+001 6080
TV022 Legal Lookup 77 Service Blvd. Houston TX 3.21516E+003 7230
TV023 World Wide Learning U 11 Boyardee Drive Freeport MA 7.71060E+002 6510
TV024 Enterprise Transport 98 New Worlds Blvd. Freeport MA 1.23498E+003 6500
TV025 Against the Tide 54 All Detergent Way Orlando FL 6.47200E+001 4110
TV026 Clampett Oil 4268 Jethro Blvd. Dallas TX 0.00000E+000 4030
TV027 Narrow Nest 23 Georgia Drive Toledo OH 1.60900E+003 4110
TV028 Distant Horizons 1917 Douglas Way Chicago IL 2.69800E+001 7230
TV029 Paltry Play 1818 Johnson Blvd. Chicago IL 1.00000E+003 6080
TV030 Make Shift Tilts 4 Holiday Way Chicago IL 1.79323E+003 7230
Table of Contents

Legal Dot Privacy