HDTutorial
EN

Playback starts YouTube’s embedded player (privacy-enhanced mode).

05 MySQL Tutorial for Beginners: Arithmetic Expressions, AS: Column Alias

6,824 views November 11, 2015 11:41

Watch on YouTube
Channelgolearnfast

Description from the creator

In the SELECT clause, you can code an expression that include one or more arithmetic operators.
An expression is a combination of column names, numbers and operators and evaluates to a single value.
There are several arithmetic operators you can use in the arithmetic expressions (addition, subtraction, multiplication, division, integer division and modulo)

In mathematics "order of precedence" is a rule used to clarify which procedures should be performed first in a given mathematical expression.
In arithmetic expressions, MySQL performs multiplication, division, DIV and MOD operations first.
Then, it performs addition and subtraction operations. The operations in an expression are performed from left to right.

You can use parentheses in an expression, to specify how an expression is evaluated and override the order of precedence rule.
MySQL evaluates the expressions in the innermost sets of parentheses first, followed by the expressions in outer sets of parentheses.

Within each set of parentheses, MySQL evaluates the expression from left to right in the order of precedence.

By default, a column in the result set is given the same name as the column in the base table.
If the column is based on a calculated value, MySQL uses the expression for the calculated value as the column name.
Since the expressions for many calculated values can be cumbersome you can specify a substitute name known as a "column alias" for the column.
To assign a column alias, you code the column specification followed by the AS keyword and the new name.
Although the AS keyword is optional, it’s recommend you code it for readability.
To include a space in the alias you can enclose that alias in single quotes.

EXERCISES for your SELF-TRAINING:
golearnfast.com/Quizzes.php?_SelectSmallerGroup…

SCRIPT FOR THE EXAMPLES:
golearnfast.com/files/lessons_material/lesson_2…

SUBSCRIBE!
youtube.com/channel/UCMEaGDoHU7c9tWyafZ9vC6Q?su…

FACEBOOK
facebook.com/golearnfast

GOOGLE+
plus.google.com/u/0/b/101326338689489366802/

About this tutorial

golearnfast published this 11:41 video tutorial on November 11, 2015. It has been watched 6,824 times on YouTube.

Category
Education
Duration
11:41
Published
November 11, 2015
Views
6,824
Likes
41

Tags

Share

This tutorial in other languages