Explanation of Retrieving Columns of Data from a Database Table by Ron Kurtus - Succeed in Using SQL. Key words: Structured Query Language, Access, MySQL, MS SQL Server, SELECT, wildcard, comma, Ron Kurtus, School for Champions. Copyright © Restrictions
Retrieving Columns of Data from a Database Table in SQL
by Ron Kurtus (3 February 2007)
You can use SQL to retrieve the columns of a database table with the SELECT statement. You can retrieve all columns, a single column, or several specific columns. It is then up to your programming language to display that data.
Questions you may have include:
- How do you retrieve all columns?
- How do you retrieve a single columns?
- How do you retrieve selected columns?
This lesson will answer those questions.
Retrieve all columns
You can query a database to retrieve all the elements in a database table by using the SELECT statement and wildcard (*) indicator.
Note: It is standard practice to add ";" at the end of your SQL query. Some databases require it and some don't.
Retrieve single column
The most common query from a database is to collect or retrieve all the elements in a specific column of the database table.
Retrieve several select columns
You can also retrieve data from several columns by separating the column names with a comma.
SELECT column_1, column_2, column_7
Note: Do not place a comma after the last item in the list, because it will result in an error message.
The SELECT statement is used to retrieve the columns of a database table. You can retrieve all columns, a single column, or several specific columns.
Use good tools
Resources and references
Questions and comments
Do you have any questions, comments, or opinions on this subject? If so, send an email with your feedback. I will try to get back to you as soon as possible.
Click on a button to bookmark or share this page through Twitter, Facebook, email, or other services:
Students and researchers:
The Web address of this page is:
Please include it as a link on your website or as a reference in your report, document, or thesis.
Where are you now?
Retrieving Columnsof Data from a Database Table in SQL