Solved

SQL Query Between Two Letters

Posted on 2013-11-27
4
398 Views
Last Modified: 2013-11-27
How can I query all data where a field where all values (first letter) are between to alpha characters.  Say I want to query where the last name is between "A" and "H".

Here is the query I need to filter:

sql="SELECT p.LastName FROM Participant p INNER JOIN PartRace rc ON rc.ParticipantID = p.ParticipantID WHERE rc.RaceID = " & lWhichRace

Thanks!
0
Comment
Question by:Bob Schneider
  • 2
4 Comments
 
LVL 25

Assisted Solution

by:Shaun Kline
Shaun Kline earned 166 total points
ID: 39680685
Add:
AND LEFT(p.LastName, 1) BETWEEN 'A' and 'H'

Open in new window

0
 
LVL 9

Assisted Solution

by:guswebb
guswebb earned 334 total points
ID: 39680689
Assuming the field upon which you want to perform the A - H check is lastname, use...

select lastname from participant p, partrace rc where p.articipantid=rc.raceid and LEFT(lastname,1) = [A-H]
0
 
LVL 9

Accepted Solution

by:
guswebb earned 334 total points
ID: 39680698
small correction (single quotes)....

select lastname from participant p, partrace rc where p.articipantid=rc.raceid and LEFT(lastname,1) = '[A-H]'
0
 

Author Closing Comment

by:Bob Schneider
ID: 39680716
Thanks!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

708 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

15 Experts available now in Live!

Get 1:1 Help Now