I want to be able to select only the field where a certain field contains both letters and numbers. for example:
Select [field1], [field2]
from [db1].[tabl
LIKE will do it. This is a double negative
where [field2] NOT LIKE '%[^0-9a-z]%'
It says:
%[^0-9a-z]% means not (alphanumeric)NOT LIKE '%[^0-9a-z]%' means not(not(alphanumeric)) -> alphanumericEdit:
For all numbers... "it works"
SELECT 'it works' WHERE '1234567' NOT LIKE '%[^0-9a-z]%'
All letters
SELECT 'it works' WHERE 'abcdefg' NOT LIKE '%[^0-9a-z]%'
Contains non-alphanumeric
SELECT 'it works' WHERE 'abc_123' NOT LIKE '%[^0-9a-z]%'
Edit 2:
This solution is for
only alphanumeric, any mixture of letters and numbers
Edit 3:
letters followed by numbers
where [field2] NOT LIKE '%[^0-9a-z]%' AND [field2] LIKE '[a-z]%[0-9]'
Edit:
Finally, 2 letters and upto 3 numbers
where
[field2] LIKE '[a-z][a-z][0-9]'
OR
[field2] LIKE '[a-z][a-z][0-9][0-9]'
OR
[field2] LIKE '[a-z][a-z][0-9][0-9][0-9]'