Database Reference
In-Depth Information
Analysis
The RTrim() function trims all spaces from the right of a value. By using
RTrim() , the individual columns are all trimmed properly.
Note
The Trim() Functions In addition to RTrim() (which, as just seen, trims the right
side of a string), MariaDB supports the use of LTrim() (which trims the left side of a
string), and Trim() (which trims both the right and left).
Using Aliases
The SELECT statement used to concatenate the address field works well, as seen
in the previous output. But what is the name of this new calculated column?
Well, the truth is, it has no name; it is simply a value. Although this can be fine
if you are just looking at the results in a SQL query tool, an unnamed column
cannot be used within a client application because the client has no way to
refer to that column.
To solve this problem, SQL supports column aliases. An alias is just that, an
alternative name for a field or value. Aliases are assigned with the AS keyword.
Take a look at the following SELECT statement:
Input
SELECT Concat(RTrim(vend_name), ' (', RTrim(vend_country), ')') AS vend_
title
FROM vendors
ORDER BY vend_title;
Output
+-------------------------+
| vend_title |
+-------------------------+
| ACME (USA) |
| Anvils R Us (USA) |
| Furball Inc. (USA) |
| Jet Set (England) |
| Jouets Et Ours (France) |
| LT Supplies (USA) |
+-------------------------+
 
 
Search WWH ::




Custom Search