Question:
how can i select a specific attribute from a view in mssql.if i write "select *..." than its ok.?
ashiqur_robin
18 years ago
i have created a view in mssql. i want to select specific attributes from that view. when i write (select *.. where...) then i get all the attributes. but when i write (select [specific attribute]..) then i got an error message.i am using ASP.NET 2.0 with C#. please somebody help me. thanks.....Robin
Four answers:
jools
18 years ago
The structure is as follows:



SELECT column1, column2, column3 FROM view



e.g If your view consisted of the following columns



Id, FirstName, LastName



and the view was called vw_AddressBook,



then the SQL Statement you need to write is:



SELECT Id, FirstName, LastName from vw_AddressBook



Should retrieve The Id, FirstName and LastName for all records in the view. If you wanted for example to omit the Id column from your results, you would write the following SQL

Statement:



SELECT FirstName, LastName from vw_AddressBook



Hope this helps
Josh H
18 years ago
Remember, mysql is case sensitive. (unless that is disabled)



Also, if you can, you should test your queries in a mysql interface, rather than from programming, as the language sometimes alters the queries. Also, the mysql interface often gives more useful error messages.
Smutty
18 years ago
Is the [SpecificAttribute] you are specifying in the View or in the Table behind it? I think this is were your problem lies.
anonymous
18 years ago
i think yes


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...