var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Select based on character position within string
I am trying to write a query that creates a popup input box based on the 6th and 7th character within a string.
Field is StationID, example = (2012080100205). This field is a concatenation of year (4 digits), ship code (2 digits), cruise number (2 digits), station number (3 digits) and event number (2 digits).
I would like to create a query where people can search for data based on the ship code (characters 6 and 7) within this field.
Is this possible?
I've tried variations on the Left, Right, Mid functions, i.e.;
Left([StationID],7) = '8', just to select based on these positions, But no luck so far.
Any help would be greatly appreciated!
You must use the Mid() function in this case:
You could also use the Like operator:
SELECT... FROM... WHERE Mid(StationID, 6, 2) = '85'
In the first case, you extract 2 characters, beginning at the sixth position. In the second, you extract from the sixth position to the end of the string.
SELECT... FROM... WHERE Mid(StationID, 6) Like '8*'
Note: This kind of query can be slow if the number of rows is important because each row must be processed and no index can be used to evaluate the criteria.
Have a nice day!
Sweet, got it.. Thanks Sinndho!!