Introduction
MySQL is a powerful relational database management system (RDBMS). It lets you store massive data for big e-commerce or heavy business activities. If you are an intermediate candidate who have an upcoming interview, then you must prepare well for MySQL interview questions . This article consists of 50 intermediate MySQL interview questions and answers to help you test your skills and boost your confidence.
Must Read: 50 BASIC MYSQL INTERVIEW QUESTIONS Top 50 Intermediate MySQL Interview Questions
1. What are the ways to insert the NULL values?
First, by omitting a column from the column list, and second, by specifying the NULL keywords in the VALUES clause.
2. Which MySQL query do we use to find the second-highest salary from the employee table?
We use the LIMIT clause MySQL to find the second-highest salary:
SELECT DISTINCT salary
FROM employees
ORDER BY salary DESC
LIMIT 1 OFFSET 1; 3. Explain the difference between RDBMS, DBMS, and Database.
| Database management systems (DBMS) | Relational database management system (RDBMS) | Database |
|---|---|---|
| It is software used to store, retrieve, and run queries on data. Examples of the DBMS are MySQL, MariaDB, PostgreSQL, Microsoft SQL Server, Oracle Database, and Microsoft Access. | It is a type of DBMS relational model that stores a large amount of data in a table. An example of RDBMS is a SQL server. | It is a collection of data organized in a structured way. It can be a relational database, NoSQL database, or hierarchical database. |
4. What do you mean by self-referencing the foreign key? Write the MySQL query showing self-referencing the foreign key.
A foreign key stored in the table on its own is called a self-referencing one.
CREATE TABLE 'Student'
'name' VARCHAR(30) NOT NULL,
'student_id' CHAR(10) NOT NULL,
'classteacher_id' CHAR(9) NOT NULL,
'Marks' decimal(15, 7) NULL,
PRIMARY KEY ('student_id')
FOREIGN KEY ('classteacher_id') REFERENCE student(student_id) ON DELETE CASCADE 5. What is the function to calculate the average salary?
The AVG function is what we use to calculate the average salary.
SELECT AVG(salary)
FROM employees; 6. What are the four categories of SQL queries?
The four categories are:
Data Definition Language (DDL): It includes the basic SQL commands such as CREATE which creates the databases, tables, view, and schema. and define the structure, columns, data types, and constraints of the object.
- DROP: It permanently deletes a database object.
- ALTER: It allows modification of the structure of existing database objects, by adding or dropping columns in a table.
- TRUNCATE: It deletes all data from a table while keeping its structure unchanged.
- ADD COLUMN: Adds any column to the table schema
Data Manipulation Language (DML): It is used to manipulate the data in the database. The following are the SQL commands that come under DML:
- SELECT INTO: It selects data from one table and then inserts it into another.
- INSERT: It inserts data or records into a table.
- UPDATE: It updates the value of any record in the database.
- DELETE: It deletes records from a table.T§ The author
Top 50 Intermediate MySQL Interview Questions
Whether you are a fresher or an experienced candidate, these top 50 intermediate MySQL interview questions will help you test your skills.
PublishedApril 19, 2024
Categoryintermediate mysql questions
Don’t miss the next one.
We publish essays on engineering, hiring, and building teams. Subscribe and we’ll send them when they land.
Unsubscribe anytime · one letter, never more