Click here to Skip to main content
16,007,760 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Please I need your help guys,

How do I create a query that will automatically add columns, Im not sure this will make sense. Example

I have a query that select name,surname and age from person table and now I want to add another field like phone number but I want my query to automatically detect that the is a field added so that I dont manually add fields all the time.

Is this possible and How do I go about?

Help me please.
Posted
Updated 29-Sep-10 20:26pm
v2
Comments
AspDotNetDev 30-Sep-10 2:27am    
FYI, I changed the title of your question. In the future, choose more descriptive titles than "Help Please".

1 solution

The asterisk selects all columns in a table:
SQL
SELECT * FROM TheTable

If you are doing a JOIN between multiple tables, you can even specify which table to get columns from:
SQL
SELECT TheTable.* FROM TheTable
JOIN AnotherTable ON SomeValue = SomeOtherValue

There are also more advanced techniques, such as inspecting the system tables to see which columns a table has, then building a query as a string and executing it dynamically, but that is probably beyond what you are looking for at this time.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900