Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
547 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
Written by Andrew Gould
In this tutorial
The SELECT list in a query is used to specify the columns you want to see in the results. Just as with table names you can drag column names in from the Object Explorer window, use the Intellisense feature to insert them, or simply type them in.
Before you can drag a column name into a query you'll need to expand the relevant folders, as shown in the diagram below:
Expand the database you are working in, then the Tables folder, followed by the table you are using and finally the Columns folder.
You can now simply drag the column names into the query between the SELECT and FROM keywords:
The column names must appear after the SELECT keyword and before the FROM keyword.
It's potentially much quicker to use the Intellisense feature to add column names to a query, especially if you've already added a table name to the FROM clause of the query:
Simply start typing the name of a column to make the Intellisense list appear.
You can add multiple column names to the SELECT list either on a single line or with each column name on a separate line. You must add a comma before each extra column that you are listing:
You can add as many column names as you like, just make sure to separate them with commas.
If you list your column names on separate lines you can add a comma to either the end of a line or the start:
You can add commas to the end of a column name on one line... | ... or to the start of the name on the following line. |
To begin with it might seem a bit odd typing a comma at the start of a line but I think it makes it much easier to spot when you've accidentally missed one out or added too many.
You can alter the name of a column in your query by giving it an alias. You can do this simply by typing the title you want to use immediately after the column name:
If your alias is a single word, such as Title, you can type it in after the column name as shown here.
Although it isn't necessary, you can add the AS keyword to make your aliases more obvious:
Put the AS keyword between the column name and alias to make the alias stand out.
If you want to use an alias that includes two or more separate words you'll need to enclose the alias in either a set of square brackets or a set of single quotes:
You can use either square brackets or single quotes to enclose a multi-word alias.
Now that you've added some column names to the SELECT list you have a complete query that is ready to be executed. The next part of this tutorial explains how to execute your query.
You can learn more about this topic on the following Wise Owl courses:
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.