MySQL String - Exercises, Practice, Solution
MySQL string [17 exercises with solution]
[An editor is available at the bottom of the page to write and execute the scripts.]
1. Write a query to get the job_id and related employee's id. Go to the editor
Partial output of the query :
job_id | Employees ID |
AC_ACCOUNT | 206 |
AC_MGR | 205 |
AD_ASST | 200 |
AD_PRES | 100 |
AD_VP | 101 ,102 |
FI_ACCOUNT | 110 ,113 ,111 ,109 ,112 |
Sample table: employees
2. Write a query to update the portion of the phone_number in the employees table, within the phone number the substring '124' will be replaced by '999'.
Sample table: employees
3. Write a query to get the details of the employees where the length of the first name greater than or equal to 8. Go to the editor
Sample table: employees
4. Write a query to display leading zeros before maximum and minimum salary. Go to the editor
Sample table: jobs
5. Write a query to append '@example.com' to email field.
Sample table: employees
Sample Output :
EMAIL -------------------- [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] - - - - - - - - - - - - - - - - - - - - - -
6. Write a query to get the employee id, first name and hire month. Go to the editor
Sample table: employees
7. Write a query to get the employee id, email id (discard the last three characters). Go to the editor
Sample table: employees
8. Write a query to find all employees where first names are in upper case. Go to the editor
Sample table: employees
9. Write a query to extract the last 4 character of phone numbers. Go to the editor
Sample table: employees
10. Write a query to get the last word of the street address. Go to the editor
Sample table: locations
11. Write a query to get the locations that have minimum street length. Go to the editor
Sample table: locations
12. Write a query to display the first word from those job titles which contains more than one words. Go to the editor
Sample table: jobs
13. Write a query to display the length of first name for employees where last name contain character 'c' after 2nd position. Go to the editor
Sample table: employees
14. Write a query that displays the first name and the length of the first name for all employees whose name starts with the letters 'A', 'J' or 'M'. Give each column an appropriate label. Sort the results by the employees' first names. Go to the editor
Sample table: employees
15. Write a query to display the first name and salary for all employees. Format the salary to be 10 characters long, left-padded with the $ symbol. Label the column SALARY. Go to the editor
Sample table: employees
16. Write a query to display the first eight characters of the employees' first names and indicates the amounts of their salaries with '$' sign. Each '$' sign signifies a thousand dollars. Sort the data in descending order of salary. Go to the editor
Sample table: employees
17. Write a query to display the employees with their code, first name, last name and hire date who hired either on seventh day of any month or seventh month in any year. Go to the editor
Sample table: employees
More to Come !
MySQL Code Editor:
Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework