Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I saw a SQL where they have used a

Status
Not open for further replies.

az12345

Technical User
Nov 15, 2003
2
US
I saw a SQL where they have used a view definition along with the view name to select some fields from the view like:
select field1, field2, field3 from
(select field1, field2, field3, field4,field5 from
table1 and table where ----)view_name

The SQL inside the paranthesis is exacly same as the definition of the view whose name is also given in the SQL. Why is it required? Only the view name can be used or the whole SQL used to create the view can be used. But why both were used? May be to increase performance?
 
AZ,

In your code, above, "view_name" is NOT a VIEW coming from a definition in your database; in this case, "view_name" is simply an ALIAS of your IN-LINE "virtual view" definition. Whoever coded your virtual view wanted to give the definition and alias. In this case, the alias is optional.

To clarify, there may be a VIEW definition in your database named "view_name", but your SQL code, above, is not using a VIEW definition from your database; it is using a VIEW that your SQL statement defines virtually and in-line.

If this did not answer your question satisfactorily, I'm happy to try another explanation. Please let us know.

Dave
Sandy, Utah, USA @ 17:52 GMT, 10:52 Mountain Time
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top