Select value from select statement

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a select statement and I want to select value from this statement. I
did try the following statement but is not working:
SELECT mytable.ID
FROM SELECT ID
FROM TableName WHERE TableName.ID In (1,2,3,4,5) as mytable
Where mytable.id = 3;

I am using access 2003 Any Idea.
Thanks for help in advance.
 
SELECT mytable.ID
FROM SELECT ID
FROM TableName WHERE TableName.ID In (1,2,3,4,5) as mytable
Where mytable.id = 3;

It's a bit hard to know what you are trying to achieve, but you are
making it much arder than it needs to be:

- You've only mentioned one table, so presumably that's the
table you want to query;

- You mention two criteria for the ID value, so you have to
make up your mind about which you want.

Try this:

SELECT Id
FROM TableName
WHERE Id IN (1,2,3,4,5)



and this will give you a set of ID's in that range. The other thing you
might be getting at is a bit redundant:

SELECT Id FROM TableName WHERE Id=3

All the best


Tim F
 
Look at the sql statement. You are just getting the number 3. The inner
query returns a table of {1,2,3,4,5}, then the outer query returns from this
the number 3. Either that or you are giving us a bad example.

Dom

--
Dominic Olivastro
ipIQ, Inc.

web: http://www.ipIQ.com
fax: 1-856-546-9633
voice: 1-856-546-0600 (ext 224)
email: (e-mail address removed)
 
Back
Top