Detailed description of how to name a shard using the mysql Command Line

Source: Internet
Author: User

The mysql command line can implement many powerful functions. The mysql command line provides a natural alias for a column name. The following describes how to implement the mysql command line for a column name for your reference.

If a column is given a pseudonym?
The mysql keyword-AS is used to name a column.

For example, you can name the preceding example as Average Income, as follows:

 
 
  1. select sum(salary) + sum(perks) AS 'Average Income' from employee_data;  
  2. +----------------+  
  3. | Average Income |  
  4. +----------------+  
  5. |        2387000 |  
  6. +----------------+  
  7. 1 row in set (0.01 sec)  
  8.  

Note: If a Kana contains spaces, you must enclose the Kana in quotation marks.

In the case of actual column names and lengths, the use of Kana should make the results more intuitive. The following is another example to calculate the ratio of extra employee allowance to salary.

 
 
  1. select (SUM(perks)/SUM(salary) * 100)  
  2. AS 'Perk Percentage' from  
  3. employee_data;  
  4.    
  5. +-----------------+  
  6. | Perk Percentage |  
  7. +-----------------+  
  8. |           19.53 |  
  9. +-----------------+  
  10. 1 row in set (0.00 sec)  
  11.  

Note: If the query result needs to be directly converted to a PHP variable, the alias is required in the preceding example. You cannot name the variable "$ sum (perks) /sum (salary) * 100? In addition, Kana cannot contain spaces, so the Kana that can be directly used by the most PHP variable should be perk_percentage.
 

Special usage of the SELECT command in MySQL

Troubleshooting of MySQL command line garbled

Two methods to fix mysql tables

How to insert an array into a mysql table in php

MySQL Data Table Traversal method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.