SQL Tutorial 20: Write a query to extract middle name from full name

SQL Tutorial 20: Write a query to extract middle name from full name

368 Lượt nghe
SQL Tutorial 20: Write a query to extract middle name from full name
Watch the entire SQL playlist here: https://www.youtube.com/playlist?list=PL_neLGJ5LPUzPIg96tf7rXb57D6-3n5Pq About me: I'm Parag, with three years of experience in the field of Data Science. Most recently, I worked as a Business Intelligence Engineer in New York. I also hold a Master's degree in Data Science from the University of Massachusetts. In this tutorial, we’ll learn how to extract the middle name from a full name in SQL using the CHARINDEX() and SUBSTRING() functions. If you’ve ever needed to split a full name into its individual components (first name, middle name, last name), this video will show you exactly how to do it. Schema & Sample Data: CREATE TABLE People ( ID INT PRIMARY KEY, FullName VARCHAR(255) ); INSERT INTO People (ID, FullName) VALUES (1, 'Amit Kumar Sharma'), (2, 'Priya Ramesh Iyer'), (3, 'Raj Singh'), -- No middle name (4, 'Neha Anil Patil'), (5, 'Vikram Suresh Nair'), (6, 'Sonia Gupta'); -- No middle name -- Expected Output: -- FullName MiddleName -- Amit Kumar Sharma Kumar -- Priya Ramesh Iyer Ramesh -- Raj Singh NULL -- Neha Anil Patil Anil -- Vikram Suresh Nair Suresh -- Sonia Gupta NULL -- Syntax: substring(string, start_position, length) -- Syntax: charindex(substring, string, [start_position]) -- Ajay Ra K -- 123456789 Follow me on LinkedIn: https://www.linkedin.com/in/paragtech/ Relevant Hashtags: #SQL #Database #SQLQuery #SQLInterview #LearnSQL #DataScience #SQLChallenge #SQLTutorial #SQLForBeginners #SQLQueries #SQLServer #MySQL #PostgreSQL #SQLPractice #SQLDeveloper #CodingChallenge #TechInterview #DataAnalytics #SQLExercises #Programming #SoftwareDevelopment