Query queried results ?

The only way to query a query is using "INTO TABLE" right?
Like for example I have
SELECT * INTO NEWTABLE1
FROM MAINTABLE

then I'll later say SELECT * INTO NEWTABLE1 FROM NEWTABLE1
and so on to get the query result of the query result .
Now when I use such a statement in VB it says " the table already exists " so I will have to DROP the table after I write to a new table . In between this operation its purposeless if I dont write the output on to a GRID or EXCEL sheet ..I'm getting errors when I try to do that ...
How to accomplish this ?
Please let me know .
Thanks .
[626 byte] By [Beginner2002] at [2007-11-17 17:10:18]
# 1 Re: Query queried results ?
Hi,

As far as I've understood your problem, you want to requery a query (I dunno for what). Well, my guess says that you do not need the 'INTO Table' thing at all. Query in the normal way. But this still does not answer, why you need to query AGAIN??

Gud luk
Arun
nmarun at 2007-11-10 0:22:36 >
# 2 Re: Query queried results ?
I've been working with SQL SP and we can do query in a query. The query looks like this but I'm not sure if it will work with Access DB.

SELECT
*
FROM
(SELECT * FROM dbo.sysobjects WHERE [XTYPE] = 'U') a
WHERE
a.[NAME] LIKE '%log%'

-Cool Bizs
coolbiz at 2007-11-10 0:23:36 >
# 3 Re: Query queried results ?
Ok what you wanna do ?
The into statement sends the data in a new table

if you create a table and want to select the same record you don't need the into statement.

Example

Select * into table2 from table1

( now that the table is created )

if you want the same records you don't need to RECREATE the table.

Select * from table2 will give you all the records you inserted in table 2

But if you wanna do a sub-Query of a query here's the syntax

Select * from (SELECT * From table2 ) [where condition]

where the brackets means it's optional.

so a from clause can contain either a table or a query or even a sub-query of a query.. Example

Select * from (Select * from ( Select * from table2))

But I've never seen more than 3 levels of queries and some Database might not support more than 2 levels.
Boumxyz2 at 2007-11-10 0:24:42 >