SUBSTR in query

G

Guest

Did not think this would be so difficult.
I just want to add a SUBSTR to capture the first 5 digits of a field.
AM I close???



SELECT
SUBSTR (MBR_GROUPNO, 1,5)
From tblMember

Or this one???

SELECT tblMember.MBR_GROUPNO
FROM tblMember
WHERE (((tblMember.MBR_GROUPNO)="need a substr"));
 
M

Marshall Barton

Dan @BCBS said:
Did not think this would be so difficult.
I just want to add a SUBSTR to capture the first 5 digits of a field.
AM I close???

SELECT
SUBSTR (MBR_GROUPNO, 1,5)
From tblMember

Or this one???

SELECT tblMember.MBR_GROUPNO
FROM tblMember
WHERE (((tblMember.MBR_GROUPNO)="need a substr"));


Access/Jet do not have a SubStr function.

Try using:

SELECT Mid(MBR_GROUPNO, 1, 5)
From tblMember

Or

SELECT MBR_GROUPNO
FROM tblMember
WHERE MBR_GROUPNO Like "abcde*"
 
G

Guest

The below code works!
Now, how can I specify a specific criteria, I tried adding the criteria,
also tried creating another query from this one. But the dependence is wrong.

I need to add only MBR_GROUP_5: Left(MBR_GROUPNO,5) = 70395 and 70396

SELECT Left(MBR_GROUPNO,5) AS MBR_GROUP_5, tblTrackingData.MEMBERNO
FROM ((tblMember INNER JOIN tblTrackingData ON tblMember.MEMBERNO =
tblTrackingData.MEMBERNO) INNER JOIN tblCaseLog ON tblTrackingData.ICNNO =
tblCaseLog.ICNNO) INNER JOIN tblCoordinators ON
tblTrackingData.TR_GRIEVANCECOORDINATOR = tblCoordinators.GC_RACF;
 
J

John Spencer

SELECT Left(MBR_GROUPNO,5) AS MBR_GROUP_5, tblTrackingData.MEMBERNO
FROM ((tblMember INNER JOIN tblTrackingData ON tblMember.MEMBERNO =
tblTrackingData.MEMBERNO) INNER JOIN tblCaseLog ON tblTrackingData.ICNNO =
tblCaseLog.ICNNO) INNER JOIN tblCoordinators ON
tblTrackingData.TR_GRIEVANCECOORDINATOR = tblCoordinators.GC_RACF
WHERE Left(MBR_GroupNo,5) in ("70395","70396")

OR you could possibly use

WHERE MBR_GroupNo Like "7039[56]*"

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
G

Guest

That did it - thanks

John Spencer said:
SELECT Left(MBR_GROUPNO,5) AS MBR_GROUP_5, tblTrackingData.MEMBERNO
FROM ((tblMember INNER JOIN tblTrackingData ON tblMember.MEMBERNO =
tblTrackingData.MEMBERNO) INNER JOIN tblCaseLog ON tblTrackingData.ICNNO =
tblCaseLog.ICNNO) INNER JOIN tblCoordinators ON
tblTrackingData.TR_GRIEVANCECOORDINATOR = tblCoordinators.GC_RACF
WHERE Left(MBR_GroupNo,5) in ("70395","70396")

OR you could possibly use

WHERE MBR_GroupNo Like "7039[56]*"

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Dan @BCBS said:
The below code works!
Now, how can I specify a specific criteria, I tried adding the criteria,
also tried creating another query from this one. But the dependence is
wrong.

I need to add only MBR_GROUP_5: Left(MBR_GROUPNO,5) = 70395 and 70396

SELECT Left(MBR_GROUPNO,5) AS MBR_GROUP_5, tblTrackingData.MEMBERNO
FROM ((tblMember INNER JOIN tblTrackingData ON tblMember.MEMBERNO =
tblTrackingData.MEMBERNO) INNER JOIN tblCaseLog ON tblTrackingData.ICNNO =
tblCaseLog.ICNNO) INNER JOIN tblCoordinators ON
tblTrackingData.TR_GRIEVANCECOORDINATOR = tblCoordinators.GC_RACF;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top