Select Names Starting With Vowels in MS SQL Server

Introduction

Sometime we may need to select the column results that the string starts with Vowels. In this article, We will have a look, How to select the columns results starting with Vowels.

Example

As an example, we have a StudentDetails table, first lets select all the results from the table.

SELECT [StudentId]
      ,[FirstName]
      ,[LastName]
      ,[RegistrationNumber]
      ,[Degree]
      ,[CreatedDate]
      ,[CreatedBy]
  FROM [PracticalWorks].[Details].[StudentDetails]

The above query’s result is as shown below,

Fig.1 Entire Table Result

Now lets select student names starting with Vowels.

SELECT [StudentId]
      ,[FirstName]
      ,[LastName]
      ,[RegistrationNumber]
      ,[Degree]
      ,[CreatedDate]
      ,[CreatedBy]
  FROM [PracticalWorks].[Details].[StudentDetails]  
  WHERE LEFT(FirstName,1) in ('A','E','I','O','U');

The where clause applies the required condition. The LEFT function is used to access the first letter in this case. We want the first letter to be in the provided list of values which are the vowels.

Fig.2 Names Starting with Vowels

Conclusion

In this article we have discussed about selecting the columns results starting with Vowels. I hope you all found this article useful. Please share your feedback in the comment section.

17 thoughts on “Select Names Starting With Vowels in MS SQL Server

Add yours

  1. Hi Sundaram Subramanian,
    The query can be written more easily using LIKE operator which returns same result.
    SELECT*
    FROM [dbo].[tblEmployee]
    WHERE EmployeeFirstName LIKE ‘[A,E,I,O,U]%’
    This would not give an extra burden to learn LEFT Operator. Thought?

    Liked by 1 person

  2. Pingback: Learn With Sundar

Leave a Reply to Sundaram Subramanian Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Website Built with WordPress.com.

Up ↑

%d bloggers like this: