General information
Category:
Coding, syntax & commands
Title:
SQL to select left character if a number but not a letter
Hello everyone,
I have a field in a table that consists of both numbers and letters. I would like to have a SQL statement that will select the first character in that field and if it is greater than "2" then show the number otherwise show "0". The SQL I use now does that but if there is a letter as the first character access shows it as '#Error' but I would like it to show "0" if it is a letter or number less than 2. This is the SQL I have tried:
SELECT Iif(Left([myField],1)>2, Left([myField],1),"0")
FROM MyTable;
Can anyone please help with this SQL statement?
Thank you!
Max
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only