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.

Responses

  1. […] Select Names Starting With Vowels in MS SQL Server […]

    Liked by 1 person

  2. […] Select Names Starting With Vowels in MS SQL Server […]

    Liked by 1 person

  3. Rakesh Kumar Avatar

    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

  4. Sundaram Subramanian Avatar

    Yes, the query mentioned by you will work for the example table which I have used. But this will not work in the case of a “Single Column” holds both First and Last names. In that case, have to use the logic mentioned in this Article.

    Liked by 1 person

  5. […] Select Names Starting With Vowels in MS SQL Server […]

    Like

  6. […] Select Names Starting With Vowels in MS SQL Server […]

    Like

  7. […] Select Names Starting With Vowels in MS SQL Server […]

    Like

  8. […] Select Names Starting With Vowels in MS SQL Server […]

    Like

  9. […] Select Names Starting With Vowels in MS SQL Server […]

    Like

  10. […] Sometime we may need to select the column results that the string ends with Vowels. In this article, We will have a look, How to select the columns results ending with Vowels. In one of the articles, we discussed how to select names Starting with Vowels, please refer that article here. […]

    Like

  11. […] Select Names Starting With Vowels in MS SQL Server […]

    Like

  12. […] Select Names Starting With Vowels in MS SQL Server […]

    Like

Leave a reply to Select Names NOT Starting with Vowels in MS SQL Server – Learn With Sundar Cancel reply