BLOGS BY TOPIC▼
BLOGS BY AUTHOR▼
BLOGS BY YEAR▼
Posted by Andy Brown on 23 March 2016
You need a minimum screen resolution of about 700 pixels width to see our blogs. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.
Using the ALT key to add lots of SQL aliases at once
Sometimes it's the little things ... I'm indebted to Tobi from my course this week for this tip. Suppose you have a query like this:
SELECT
-- columns from the films table
FilmName,
FilmOscarWins AS 'Oscars',
FilmRunTimeMinutes AS 'Length'
FROM
tblFilm AS f
You want to prefix each of your columns with the alias you've given your table, to get:
SELECT
-- columns from the films table
f.FilmName,
f.FilmOscarWins AS 'Oscars',
f.FilmRunTimeMinutes AS 'Length'
FROM
tblFilm AS f
Here's the clever way to do this! Hold down the ALT key, then click and drag down the column names:

Hold down the ALT key and click and drag to select a line to the left of the column names to which you want to add an alias.
Type the table alias and a full stop in - anything you type will be inserted at the start of every selected line:

Characters that you type are added to every selected line.
Trivial, but strangely satisfying!