How do I create a table alias in MySQL

rswolff picture rswolff · Dec 11, 2009 · Viewed 66.2k times · Source

I am migrating an MS Access application (which has linked tables to a MSSQL Server) to MySQL.

As a means to overcome some MSAccess table naming problems, I am seeking a solution to add a MySQL table alias that will point to an existing table in the MySQL database. Ideally I would like to create the alias 'dbo_customers' in mysql that would point to the customers table also in mysql.

To be clear I am not wanting to alias a table name inside a query like this:

SELECT * FROM customers AS dbo_customers

But rather I would like to be able issue the following query:

SELECT * FROM dbo_customers

and have it return data from the customers table.

Answer

DrewM picture DrewM · Dec 11, 2009

Off the top of my head

CREATE VIEW dbo_customers AS
SELECT * FROM customers

Maybe not the best solution but should work as the view is updatable. Will definitely work for Read Only