Mysql field as details and instance code, mysql field as details

Source: Internet
Author: User

Mysql field as details and instance code, mysql field as details

Mysql field uses

In mysql, the select query can use the AS keyword to create an alias for the queried field. This alias is used AS the column name of the expression, and the alias can be in group, order by or HAVING. For example:

Select concat (last_name, ',', first_name) AS full_name FROM mytable order by full_name;

The AS keyword is optional when aliases are used together with select queries. The preceding SQL statement can also be written as follows:

Select concat (last_name, ',', first_name) full_name FROM mytable order by full_name;

AS is optional. If you forget to enter a comma between Query fields, MySQL uses the second field AS the alias of the first field. For example, in the following SQL statement, columnb is treated as the alias of columna:

SELECT columna columnb FROM mytable;

For this reason, we recommend that you add the as keyword when using the alias.

Mysql tables use the

A table can use tbl_name AS ALIAS_NAME or tbl_name ALIAS_NAME to specify an alias:

SELECT t1.name, t2.salary FROM employee AS t1, info AS t2 WHERE t1.name = t2.name;

SELECT t1.name, t2.salary FROM employee t1, info t2 WHERE t1.name = t2.name;

Let's look at another instance:

SELECT employee. first_name, job. title, duty. task FROM employee left join job ON employee. ID = job. id left join duty ON employee. ID = duty. id where (job. title = 'manager ');

Through this article, I hope you can understand the knowledge and materials of mysql as. Thank you for your support for this site!

Related Article

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.