I have a column which contains data starting with letters and numbers. In order to retrieve only data starts which starts with a digit, how to specify in a query?
Asked
Active
Viewed 393 times
0
-
Is the length of potential numeric data fixed or can it be any length? – Yuck Apr 14 '14 at 20:32
-
Also, see this (http://stackoverflow.com/questions/5539141/microsoft-office-access-like-vs-regex) which is not an exact duplicate but is very, very close to what you're asking. – Yuck Apr 14 '14 at 20:33
-
1I think this should help you: http://stackoverflow.com/questions/10243852/determine-if-column-value-string-starts-with-a-number – cktech Apr 14 '14 at 20:50
2 Answers
0
You can do this with a LIKE
pattern match.
SELECT * FROM YourTable WHERE YourColumn LIKE '[0-9]*'
If you will be running the query from ADO, or with OleDb from outside an Access session, use %
instead of *
as the wild card character.
SELECT * FROM YourTable WHERE YourColumn LIKE '[0-9]%'
Or you could substitute ALIKE
for LIKE
and then the query will always run the same regardless of where and how you run it.
SELECT * FROM YourTable WHERE YourColumn ALIKE '[0-9]%'

HansUp
- 95,961
- 11
- 77
- 135
-1
SELECT *
FROM YourTable
WHERE YourColumn LIKE '[0,1,2,3,4,5,6,7,8,9]*'

marc_s
- 732,580
- 175
- 1,330
- 1,459
-
Welcome to StackOverflow: if you post code, XML or data samples, **please** highlight those lines in the text editor and click on the "code samples" button ( `{ }` ) on the editor toolbar to nicely format and syntax highlight it! – marc_s Apr 14 '14 at 20:41