Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an equivalent to the SUBSTRING function in MS Access SQL?

Tags:

I want to do something like this within an MS Access query, but SUBSTRING is an undefined function.

SELECT DISTINCT SUBSTRING(LastName, 1, 1) FROM Authors; 
like image 980
CoderDennis Avatar asked Apr 30 '09 21:04

CoderDennis


People also ask

Is there a substring function in SQL?

SQL Server SUBSTRING() Function The SUBSTRING() function extracts some characters from a string.

How do I find the substring of a string in SQL query?

SQL Server CHARINDEX() Function The CHARINDEX() function searches for a substring in a string, and returns the position. If the substring is not found, this function returns 0. Note: This function performs a case-insensitive search.

Which SQL function is used to return the location of a substring in a string?

The Substring function in the SQL is used to return the portion of a string.


1 Answers

You can use the VBA string functions (as @onedaywhen points out in the comments, they are not really the VBA functions, but their equivalents from the MS Jet libraries. As far as function signatures go, they are called and work the same, even though the actual presence of MS Access is not required for them to be available.):

SELECT DISTINCT Left(LastName, 1) FROM Authors;  SELECT DISTINCT Mid(LastName, 1, 1) FROM Authors; 
like image 117
Tomalak Avatar answered Sep 19 '22 14:09

Tomalak