Sub Query Problem

  • Thread starter Thread starter Arvi Laanemets
  • Start date Start date
A

Arvi Laanemets

Hi

Something like

SELECT * FROM Table1 WHERE Table1.Somefield IN (SELET Somefield FROM Table2)
or
SELECT * FROM Table1 WHERE Table1.Somefield NOT IN (SELET Somefield FROM
Table2)
 
Hi

I've seen in the Access online help that you can use a sub query as criteria
for another, but I fail to get this working, always getting an error.

I have a table with only 1 field. This table has 4 records and these records
needs to be used as the criteria to filter the info of a query of another
bigger table. If I type the values of this table into the query criteria
section, it works, but I want to use the table's records as the criteria as
I don't want the client to change the query design.

I hope someone can make out what I'm trying to achieve and maybe help.


Thanks in advance.


Chris
 
Could you post to this thread the SQL of the query that
works and the table definition that you want to use therein.

Gerald Stanley MCSD
 
Chris-

Sounds like you need the IN predicate. On the Criteria line under the field
you want to filter with values from the second table, enter something like:

IN (Select OneField From OneFieldTable)

... where "OneField" is the name of the single field in the table you
describe below and "OneFieldTable" is the name of the table. If either of
the names have spaces in them, you'll need to enclose the names in brackets.

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
 
Back
Top