?
Solved

MS-ACCESS Select substring

Posted on 2003-11-03
3
Medium Priority
?
5,490 Views
Last Modified: 2012-05-04
Hello EVeryone,

I'm working on a a critical report and I was forced to used MS-ACCESS over ORACLE.  Now I'm stuck with a basic select statement.  Anyway, to make a long story short, I want to select the first two digits of a column in access -- how can I do this.  For eg, the column always contains a 4 character field like 4443 (this is not a number).  All I want to do is select the first two characters, in this case '44'.  Any ideas?    Please this is an urgent call -- I've attached 200 points to this question.  Thanks for your time and help!!

ITorBust
0
Comment
Question by:itorbust
[X]
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
3 Comments
 
LVL 9

Accepted Solution

by:
rherguth earned 600 total points
ID: 9673826
The expression you're looking for is LEFT()

An example:
SELECT Left(FirstName, 2) as left2 FROM Contacts;

To do this through the interface, you could just click new query in Access and then select SQL View from the View menu and type in your SQL.   If you then switch back to design view, you'll see how to set the expression with the GUI.  I suspect you're more comfortable just typing the SQL anyway.

-- Bob
0
 
LVL 15

Assisted Solution

by:namasi_navaretnam
namasi_navaretnam earned 200 total points
ID: 9675569
Access equalent of substring is MID or MID$ function.

Select Mid$('Namasi, 2, 2)  //returns "am"
0
 

Expert Comment

by:arnaudduplessy
ID: 9680000
This is for first two characters from the left:

SELECT FieldName
FROM TableName
WHERE Left([FieldName],2)="Criteria";
---------------------------------------------------
This is for mid three characters starting a the second character from the left:
SELECT FieldName
FROM TableName
WHERE  Mid([FieldName],2,3)="Criteria";
----------------------------------------------------
This is for first two characters from the right:
SELECT FieldName
FROM TableName
WHERE Right([FieldName],2)="Criteria";

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

765 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