Basic SELECT statement: Get first name of all employees table after removing white spaces from both side
MySQL Basic Select Statement: Exercise-15 with Solution
Write a query to get first name of all employees table after removing white spaces from both side.
Sample table: employees
Code:
-- Removing leading and trailing whitespace characters from the first_name column
SELECT TRIM(first_name)
-- Selecting data from the employees table
FROM employees;
Explanation:
- This SQL query removes leading and trailing whitespace characters from the values in the first_name column.
- The TRIM() function is used to perform this operation. It removes leading and trailing spaces, tabs, and newline characters from a string.
Pictorial Presentation of the above query
Result :
MySQL Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a query to get the name (for example Ellen Abel, Sundar Ande etc.) of all the employees from employees table.
Next: Write a query to get the length of the employee names (first_name, last_name) from employees table.
What is the difficulty level of this exercise?
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics