Solved

SQL Query Between Two Letters

Posted on 2013-11-27
4
410 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 26

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

785 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