MySQL Wildcards

MySQL Wildcards

MySQL Aliases

MySQL Aliases

MySQL Data Types

MySQL Data Types

MySQL Interview Questions

MySQL Interview Questions and Answers


MySQL Subquery

A MySQL support subquery, a query within another quiry or a query nested within another query. In addition, a MySQL subquery can be nested inside another subquery. Subquery is useful when you need to fetch data with complex condition.

MySQL Subquery Syntax

To rename the existing table, use the following syntax:

Syntax

SELECT firstName, lastName FROM tblCustomerLoan
WHERE officeCode IN (SELECT officeCode FROM offices WHERE country = 'USA');

Parameters:

oldtablename: The old table name that you want to rename.

newtablename: The new table name for the existing table.

MySQL RENAME TABLE examples

The following MySQL statement to rename existing table:

Example

RENAME TABLE tblCustomerLoan TO tblBankCustomer;
OR
ALTER TABLE tblCustomerLoan RENAME TO tblBankCustomer;

Note:

In the above example, we rename the existing table "tblCustomerLoan" to "tblBankCustomer".

You can use MySQL Command Line Client to rename existing table name from "tblCustomerLoan" to "tblBankCustomer". It will look like this:

Show RENAME TABLE

You can check the renamed table name by the following query:

Example

SHOW tables; 

You can use MySQL Command Line Client to show renamed table name. It will look like this: