Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-11-12 : 08:53:11
|
| Sreedhar writes "hi!!i am porting an application from access to the web. i am using asp and ms sql. in access, i have run into a situation, where the programmer has constructed one query and has used that query in another query.for example,the programmer has constructed a query called "Q01". later, in another query, he uses values such as "Q01.fields("a")"the solution i came up with is that i create a temporary table containing the values of the first query ("Q01"). and then when i am constructing the second query, i use the values from the temporary tables. but, as the queries become more and more complicated, using "transform" and "pivot", i get errors, the most common being "syntax error at "FROM" clause".is there any solution wherein i can directly use the first query in the second one, like it was done in access?i'd greatly appreciate your help on this." |
|
|
JustinBigelow
SQL Gigolo
1157 Posts |
Posted - 2002-11-12 : 09:03:58
|
You can use the first query as a derived table. For example...select city, zipfrom (select city, state, zip from table1 where country like 'USA') twhere state like 'TX' It's also common to find a nested query in the IN statement of your WHERE clause.hth,JustinHave you hugged your SQL Server today?Edited by - justinbigelow on 11/12/2002 09:04:14 |
 |
|
|
r937
Posting Yak Master
112 Posts |
Posted - 2002-11-12 : 09:12:47
|
| or declare the first query as a viewthen the second query will not need alterationthis is best when several second queries use the same first queryrudy |
 |
|
|
|
|
|
|
|