Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

SQL Query Between Two Letters

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Insert parts by customer 12 42
Pass asp session variable to a js function in an asp script 6 27
Re-appearing SQL Server Agent jobs 7 29
Html value of radio 14 27
In this article I will describe the Detach & Attach 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.
In this article I will describe the Copy Database Wizard 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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

839 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