Provide an alias to make a heading more concise or meaningful : Alias « Select Clause « SQL / MySQL






Provide an alias to make a heading more concise or meaningful

       
mysql>
mysql> CREATE TABLE date_val
    -> (
    ->  d       DATE
    -> );
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql> INSERT INTO date_val (d) VALUES('1864-02-28');
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO date_val (d) VALUES('1900-01-15');
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO date_val (d) VALUES('1987-03-05');
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO date_val (d) VALUES('1999-12-31');
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO date_val (d) VALUES('2000-06-04');
Query OK, 1 row affected (0.00 sec)

mysql>
mysql>
mysql> SELECT d, DATE_FORMAT(d,'%M %d, %Y') AS date FROM date_val;
+------------+-------------------+
| d          | date              |
+------------+-------------------+
| 1864-02-28 | February 28, 1864 |
| 1900-01-15 | January 15, 1900  |
| 1987-03-05 | March 05, 1987    |
| 1999-12-31 | December 31, 1999 |
| 2000-06-04 | June 04, 2000     |
+------------+-------------------+
5 rows in set (0.00 sec)

mysql>
mysql>
mysql> drop table date_val;
Query OK, 0 rows affected (0.00 sec)

   
    
    
    
    
    
    
  








Related examples in the same category

1.Use alias
2.Use SUM and alias
3.Use AVG and alias
4.Using Aliases
5.Select calculated value with alias
6.Alias for calculated value