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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Queries with Quotes for non-existent columns

Status
Not open for further replies.

nphani

Technical User
Feb 10, 2002
104
0
0
US
I have come across VIEWs given as :

SELECT Name, 'Non-existent-field-with-quotes' AS Something FROM myTable;

But I donot understand why would I need that "Something" when it is not present at all?

For example: this is a sample VIEW

SELECT myID, myName, myCity, myState, 'a' as a, 'b' as b
FROM myTable;

What would I do with a and b when there is no field of that type in myTable.

and this VIEW is called as:

SELECT <above_View> WHERE a='something' AND b='something';

Can somebody clarify that please...

Thanx
 
The as part of the statement gives the column a field name when you run the query. Othewise when yuou run your query it will say No column name at the top of the column for the field your are creating. THis confuses people as to what information is in the column.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top