Passing a Select Query into a paramter

B

BGuy

Hello:

I was wondering if an Access SQL statement can pass a
Select query into a parameter, example:

SET @param1 = (SELECT attr FROM table WHERE condition);

Thanks a million!

BGuy
 
T

Tom Ellison

Dear Guy:

The answer depends on whether you're writing form Jet or for MSDE.
However, I'm going to assume you mean Jet, and by parameter you mean
that this is a parameter query.

In that case, what you want done could be done using a subquery. The
value you want might be used to filter, for example:

SELECT * FROM YourTable
WHERE SomeColumn = (SELECT attr FROM table WHERE condition)

In order to work properly, the SELECT attr FROM table WHERE condition
needs to be designed so as to guarantee it will always return exactly
one row. Otherwise you can expect to see an error at runtime.

If the parameter is to be used in some other manner, please describe
it.

Hello:

I was wondering if an Access SQL statement can pass a
Select query into a parameter, example:

SET @param1 = (SELECT attr FROM table WHERE condition);

Thanks a million!

BGuy

Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top