Solved

MS Access where in clause

Posted on 2010-11-09
5
405 Views
Last Modified: 2012-05-10
Is it possible to write a where in clause in MS Access SQL?

Example:

select * from mytable where myfield in (select top 6 myfieldlookup from othertable) as t1
0
Comment
Question by:dougfosterNYC
  • 2
  • 2
5 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 34095650
yes..



0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 34095669
this is already good to go

select * from mytable where myfield in (select top 6 myfieldlookup from othertable)
0
 

Author Comment

by:dougfosterNYC
ID: 34095686
OMG.  It is the as t1 statement that screwed it up.  
 
Thanks....
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 34095702
two things

with this, the table alias cannot be placed here like this (as t1). you would place it within the from part
second, myfield must match the datatype of myfieldlookup

select * from mytable where myfield in (select top 6 myfieldlookup from othertable)

0
 
LVL 65

Expert Comment

by:rockiroads
ID: 34095722
way too slow lol
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
count all and uniques records in a table 20 30
grouping logic 6 49
how to link subforms ms/access VBA 6 30
Running Total in Access 4 20
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now