Solved

Custom "between" criteria in Access Query.

Posted on 2008-10-23
6
577 Views
Last Modified: 2013-11-29
Looking to retrieve all values between records listing AA-1 through AA-96 (ie. between "AA-1" and "AA-96"). Since its not a whole number, I assume it won't retrieve the exact values I'm looking for.
0
Comment
Question by:vacnet
  • 3
  • 3
6 Comments
 
LVL 9

Expert Comment

by:jamesgu
ID: 22789167
try this

select * from <table_name>
where convert(int, replace(<your_column_name>, 'AA-', ''))  between 1 and 96;

0
 
LVL 1

Author Comment

by:vacnet
ID: 22789246
jamesqu,

Returns "Undefined function 'convert' in expression.
0
 
LVL 9

Expert Comment

by:jamesgu
ID: 22789436
select * from <table_name>
where CInt(replace(<your_column_name>, 'AA-', ''))  between 1 and 96;

0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 1

Author Comment

by:vacnet
ID: 22789802
jamesqu,

Returns "Overflow".
0
 
LVL 9

Accepted Solution

by:
jamesgu earned 500 total points
ID: 22789821
i think you have some values other than 'AA-???' in the table, if you don't want those records,

do

select * from <table_name>
where CInt(replace(<your_column_name>, 'AA-', ''))  between 1 and 96
and <your_column_name> like 'AA-*'


0
 
LVL 1

Author Closing Comment

by:vacnet
ID: 31509336
Works perfectly! Thank you jamesqu.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

895 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

11 Experts available now in Live!

Get 1:1 Help Now