Error creating MySQL view in phpMyAdmin

Rich picture Rich · Oct 28, 2016 · Viewed 14.2k times · Source

I'm having a hard time trying to create a view in phpMyAdmin. I have a database named myDB and a table named myTable.

In phpMyAdmin I click on the SQL tab, type in :

SHOW CREATE VIEW myView;

I got this error MySQL said:

#1146 - Table 'myTable.myView' doesn't exist

I don't understand this error message at all, of course it doesn't exist, otherwise why would I want to create it in the first place? And why wouldn't mySQL allow me to create it? How do I create a view?

Thanks

Answer

Vrunda Savaliya picture Vrunda Savaliya · Jan 2, 2017
SHOW CREATE VIEW

The syntax you are using is not for creating view in SQL. it is to show the views you have created in SQL

You need to use the following syntax to create a view

CREATE VIEW view_name AS
SELECT column_name(s)
FROM table_name
WHERE condition