"Begins With" function

waffle

Registered User.
Local time
Today, 14:47
Joined
Nov 3, 2006
Messages
13
There is a filter in Excel that is called begins with and I was wondering if there is anyway to use this in a query to remove only certain items, namely our equipment is labeled, AB000 or something similar where each piece of equipment in that category starts with the same two letters and then they get numbered accordingly. I'm trying to filter them so that I can tally all the usage time for a year.
 
Use the Left function Left(fieldname,2)

Never heard of the Begins with.

Brian
 
If looking for SPECIFIC things, you can do queries with "WHERE [xyz] LIKE "XX*" ....

where XX is the two-character thing you seek and ASTERISK in the context of the LIKE operator is a wild-card.

Here is how this works....

LIKE "*XX*" - same as "CONTAINS"

LIKE "XX*" - same as "BEGINS"

LIKE "*XX" - same as "ENDS"

You can also have NOT LIKE (since LIKE is an OPERATOR in this context).

Or, as Brian suggests, if all you want is a summation, use the LEFT function.

If you are doing a simple summation, use Brian's approach. But be aware that there are more complex ways to look at this if you have a complex problem involving partial matches in text fields. Note: LIKE is not well-suited for numeric fields.
 

Users who are viewing this thread

Back
Top Bottom