Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error creating MySQL view in phpMyAdmin

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

like image 711
Rich Avatar asked Oct 28 '16 13:10

Rich


1 Answers

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
like image 122
Vrunda Savaliya Avatar answered Oct 04 '22 16:10

Vrunda Savaliya