MySQL Interview Questions and Answers

Last updated on Feb 07, 2024
  • Share
MySQL Interview Questions

MYSQL is one of the most successful and leading pathways toward data administration careers. You will be amazed to know that this database service holds a total of 46.83% share in the relational database market. So to make your career and prepare for interviews in this field would be a good choice. Today we will help with these interviews by providing you with some MYSQL Interview Questions and Answers. MYSQL is one of the most popular database technologies used in the database industry. Popular companies like Microsoft, Amazon, Oracle, and IBM are using this technology on a vast basis to manage and store their data. According to one survey, nowadays more than 90% of organizations are using OSDBMS i.e. Open Source Database Management System. But to handle this database, professionals must know the MYSQL programming language.

Quick Facts About MySQL
What is the latest version of MySQL? 8.0.22 released in 19th October 2020
When was MySQL first released? 23 May 1995
Who developed MySQL? Oracle Corporation.
What language does MySQL use? C and C++ language
About License GNU Public License
Official Website

MySQL Query Interview Questions

Here in this article, we will be listing frequently asked MySQL Interview Questions and Answers with the belief that they will be helpful for you to gain higher marks. Also, to let you know that this article has been written under the guidance of industry professionals and covered all the current competencies.

Q11. How do you write IF ELSE statement in a MySQL query?

SELECT id, name, email, salary, IF(salary > 20000, 'Good', 'Average') AS type FROM `customers`;

Q12. What is indexing and how do you create an index in MySQL?

A database index is the structure of a fact that improves the velocity of operations in a table. It can be created the usage of one or greater columns, presenting the foundation for each fast random lookups and efficient ordering of getting admission to records. Indexes are used to locate rows with specific column values quickly.


CREATE INDEX [index name] ON [table name]([column name]);

Q13. Write a query to find the employee name whose salary lies in the range of 5000 and 25000.


id name email salary
101 Umesh Singh [email protected] 20000
102 Sonu Singh [email protected] 10000
103 Avinash [email protected] 7000
104 Manish [email protected] 60000
105 Rekha [email protected] 5000
106 Shiv [email protected] 20000

For this, we can use the between operator with a where clause.

SELECT id, name, salary FROM Employee WHERE salary BETWEEN 5000 AND 25000;

Q14. What are the difference between NOW and CURRENT_DATE in MySQL?
NOW() give you the current date time in the format 'YYYY-MM_DD HH:MM: SS' CURRENT_DATE() will only give you the current date in format "YYYY-MM_DD"
Q15. List some comparisons operators used in Mysql?

Comparisons operators are used to comparing one expression to another value or expression. It is just like = , < , > , => , =<, <>

Q16. How to create case insensitive query in MySQL?

The standard way to perform case insensitive queries in SQL is to use the SQL upper or lower functions like the following:

select * from users where upper(first_name) = 'AJAY';


select * from users where lower(first_name) = 'ajay';

The method is to make the field you are searching as uppercase or lowercase then also make the search string uppercase or lowercase as per the SQL function.

Q17. What is DDL, DML and DCL in MySQL?

1. DDL

In MySQL, DDL is the short form for Data Definition Language, which is used in database schemas and descriptions while deciding how data should reside in the database.

Here’s a list of DDL Queries:
  • DROP

2. DML

DML is a short form for Data Manipulation Language which is used in data manipulation and mostly includes common SQL statements to store, modify, retrieve, delete and update data in a database.

Here is the list of DML Queries:
  • CALL

3. DCL

DCL is a short form for Data Control Language including commands which are concerned with User rights, permissions and other controls within the database system.

Here’s a list of queries for DCL:
Q18. How do I import database through command line?

MySQL -u username -p database_name < file.sql
Here username is your database username like "root," database_name is your database name, file.sql is your SQL file name with complete path.

Q19. What is the use of CONCAT() in Mysql?

It is used to concatenate two or more strings.


SELECT CONCAT('BestInterview', ' ', 'Question') AS 'Name';

Q20. How to write query to get unique users in MySQL?

Table: Employee

id name email
101 Umesh Singh [email protected]
102 Sonu Singh [email protected]
103 Avinash [email protected]
104 Manish [email protected]
105 Rekha [email protected]
106 Shiv [email protected]
107 Manish [email protected]
108 Sonu Singh [email protected]

The following SQL query can be used to obtain unique or different values for a column in MySQL Table. There are different values that can be assigned to one or more columns. You must separate the column names with a comma.


SELECT DISTINCT(column_name) FROM your_table_name;




In MYSQL Database, data is stored in tabular form and that is why we also call it a Relational Database Management System. With the help of it, users can develop an infinite number of applications but it is mainly used for web applications. Talking about platforms, it can run on various platforms like LINUX, UNIX, and WINDOWS and is reliable, fast, and very easy to use. We hope these questions will help you to clear your core concepts regarding MYSQL. Let us help you with some short and important tips which might help you with your interviews-

  • MYSQL is a programming language, so always avoid YES and NO answers.
  • If you don’t know the answer, simply say I don't know rather than pretending you know.
  • Always carry a pen and notepad with you.
  • If you are stuck somewhere don’t panic, just stay calm and think out loud.
  • Go with the expectation that you will reject a lot, as “Failure is the key to Success”.
Reviewed and verified by Umesh Singh
Umesh Singh

My name is Umesh Singh having 11+ experience in Node.JS, React JS, Angular JS, Next JS, PHP, Laravel, WordPress, MySQL, Oracle, JavaScript, HTML and CSS etc. I have worked on around 30+ projects. I lo...