query for names a - l

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to query for last names that begin with a through l.....is there
a way to do that? thanks
 
Hi

If you are sure that you only want to select last beginning will L then you
can put
L* in the criteria section of you query.
But if you may want to filter for other last names and want to ask the user
to input the first letter they are searching for you could use a parameter
query
 
JRS said:
I am trying to query for last names that begin with a through l.....is
there
a way to do that? thanks

Create a calculated column with Left([LastName], 1) as its data and

Between "A" and "L" as its Criteria (use your own field name rather than
LastName)

Tom Lake
 
Another technique would be to use a wild card in your WHERE clause:

SELECT *
FROM yourTable
WHERE [Last_Name] Like "[A-L]*"

In the like clause, the use of brackets allows you to identify specific
values you want. If, for example, you wanted last names that started with
A, B, D, F, and N, you could do:

WHERE [LAST_NAME] LIKE "[A,B,D,F,N]*"

HTH
Dale
 
In addition to the solutions already suggested, you should be able to simply
specify < "m" as the criteria for the last name.
 
Douglas said:
In addition to the solutions already suggested, you should be able to simply
specify < "m" as the criteria for the last name.

That ain't necessarily so. Using a Sequence table of integers:

CREATE TABLE Test7 (
testcol VARCHAR(1) NOT NULL
)
;
INSERT INTO Test7 (testcol)
SELECT CHR(seq)
FROM Sequence
WHERE seq BETWEEN 1 AND 255
;

The following query returns 26 rows:

SELECT testcol
FROM Test7
WHERE (testcol LIKE '[A-L]*' OR testcol LIKE '[A-L]%');

whereas the following query returns 190 rows:

SELECT testcol
FROM Test7
WHERE testcol < 'm'
;

Jamie.

--
 
True, but since the OP was talking about the last names of individuals, I'm
not sure that your point is relevant to this specific case. Not many names
start with a numeric characters or a non-alphabetic character.


Jamie Collins said:
In addition to the solutions already suggested, you should be able to
simply
specify < "m" as the criteria for the last name.

That ain't necessarily so. Using a Sequence table of integers:

CREATE TABLE Test7 (
testcol VARCHAR(1) NOT NULL
)
;
INSERT INTO Test7 (testcol)
SELECT CHR(seq)
FROM Sequence
WHERE seq BETWEEN 1 AND 255
;

The following query returns 26 rows:

SELECT testcol
FROM Test7
WHERE (testcol LIKE '[A-L]*' OR testcol LIKE '[A-L]%');

whereas the following query returns 190 rows:

SELECT testcol
FROM Test7
WHERE testcol < 'm'
;

Jamie.
 
Back
Top