MySQL Wildcards

MySQL Wildcards

MySQL Aliases

MySQL Aliases

MySQL Data Types

MySQL Data Types

MySQL Interview Questions

MySQL Interview Questions and Answers


MySQL Aliases

In MySQL Aliases are usually used to give a temporary name to table, or a column. Using aliases you can make column names more readable.

MySQL ALIASES COLUMN Syntax

To give a temporary name to table, or a column., use the following syntax:

Syntax

SELECT col_name AS alias_name
FROM tablename;

MySQL ALIASES COLUMN example

The following MySQL, creates two aliases, one for the "custID" column and one for the "custName" column:

Example

SELECT firstName as Name, lastName AS LastName
FROM tblCustomerLoan;

OR

SELECT CONCAT(firstName,' ',lastName) AS Name, address
FROM tblCustomerLoan;

Note:

In the above example, we are creating two aliases, one for the "custID" column and one for the "custName" column.

You can use MySQL Command Line Client to give a temporary name to table, or a column. It will look like this:

MySQL ALIASES TABLE Syntax

To give a temporary name to table, or a column., use the following syntax:

Syntax

SELECT col1, col2,...
FROM tablename AS alias_name;

MySQL ALIASES TABLE example

The following MySQL, creates two aliases, one for the "tblCustomerLoan" table and one for the "tblCustomer" table:

Example

SELECT B.firstName, B.lastName, A.panNo,A.aadharNo
FROM tblCustomerLoan AS A, tblCustomer B
WHERE B.firstName = 'Dilip' AND A.custId = B.custId;