Help - Search - Members - Calendar
Full Version: Storing Views
Webyog Forums > SQLyog > Using SQLyog
Phatman
I'm a newbie to MySQL, I'm trying to create the equivalent of 'Queries' in Access database by using the Views tool in SQlyog. I create the views and can save them as a .sql file fine, but how do I call them from my web page? and why don't they save in SQLyog? I'm using MySQL version 5 Community edition and SQLyog 7.02 Community Edition.
peterlaursen
Your understanding is basically OK, except for one detail!

You shall not save the VIEW as an SQL file (you can do that too of course!), you should EXECUTE the CREATE VIEW ... statement - just like you execute a SELECT - or whatever - SQL statement. Once that is done you will see the view in the VIEWs folder in SQLyog Object Browser. You wil also see in SQLyog HISTORY tab that SQLyog executes the statement

CODE
select `TABLE_NAME` from `INFORMATION_SCHEMA`.`TABLES` where `TABLE_SCHEMA` = 'some_database' and `TABLE_TYPE` = 'VIEW';


.. to 'ask' the server for information about VIEWs in `some_database` database when populating the VIEWs folder.



They do not store in SQLyog, because *nothing really* (except for SQLyog's own program settings) store in SQLyog. Data (and metadata) are stored on the server - not with the client. Understanding MySQL as a *database server* that is accessed through *client(s)*, and where all communication client>>server is SQL is 'another world' than working with Access.



Was that explanation enough?
peterlaursen
... and once you have created the VIEW you can query it (almost) just like you would query a TABLE - with the most important exception that not all VIEWs are updateable (for those the underlying table(s) must be updated). That exception has effect for DELETE, INSERT and UPDATE statements, but for SELECT queries it is always true that a VIEW behaves like a table. You may even write a complex query using JOIN's and UNION's and 'mix' VIEWs and TABLEs in the statement.
Phatman
Ahh, thanks, I wasn't executing the query, that was my problem!




QUOTE (peterlaursen @ Aug 18 2008, 09:03 PM) *
Your understanding is basically OK, except for one detail!

You shall not save the VIEW as an SQL file (you can do that too of course!), you should EXECUTE the CREATE VIEW ... statement - just like you execute a SELECT - or whatever - SQL statement. Once that is done you will see the view in the VIEWs folder in SQLyog Object Browser. You wil also see in SQLyog HISTORY tab that SQLyog executes the statement

CODE
select `TABLE_NAME` from `INFORMATION_SCHEMA`.`TABLES` where `TABLE_SCHEMA` = 'some_database' and `TABLE_TYPE` = 'VIEW';


.. to 'ask' the server for information about VIEWs in `some_database` database when populating the VIEWs folder.



They do not store in SQLyog, because *nothing really* (except for SQLyog's own program settings) store in SQLyog. Data (and metadata) are stored on the server - not with the client. Understanding MySQL as a *database server* that is accessed through *client(s)*, and where all communication client>>server is SQL is 'another world' than working with Access.



Was that explanation enough?

This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.