View Full Version : Add new fields in an update query


zhuanyi
05-21-2008, 05:18 AM
Hi,
i am just wondering is there any chance I could add in new fields (columns) in an update query?
Thanks!

boblarson
05-21-2008, 06:00 AM
No, you would need to use code for an Alter Table SQL statement. But, if you are doing this, then I submit that the liklihood is that your design is flawed as you really shouldn't need to be adding columns.

Why are you adding columns?

zhuanyi
05-21-2008, 06:39 AM
thanks for the quick reply.
the reason is some of the results are calculated based on the selection results in the previous query. say for example, in the previous query, I selected the age of people, and now I want to categorize them so that if age >60 => senior, age < 20 => children, and otherwise adults and so on. the queries have to be separated for the sake of clarity.
could you help me with that? thanks!

Pat Hartman
05-24-2008, 11:50 AM
You can use queries in place of tables in a query. So query1 can select data and created calculated fields. Query2 can reference query1, including the calculated fields.