MySQL Interview Questions

Want to become an expert in cracking MySQL interview questions?

Start with practicing the questions below. Whether a question involves multiple choice or live coding, we will give you hints as you go and tell you if your answers are correct or incorrect.

After that, take our timed public MySQL Interview Questions Test.

To use our service for testing candidates, buy a pack of candidates.


1. Paginate Users

MySQL Pagination Public New

Consider the following table:

CREATE TABLE users (
  id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  username VARCHAR(50) NOT NULL
);

The following query is used to paginate the table:

SELECT * FROM users ORDER BY username LIMIT 5 OFFSET 15;

Select all the true statements about this method of pagination.

(Select all acceptable answers.)

Easy  
3min
   


2. Item Archive

MySQL Triggers Public New

Fill in the blanks so that the trigger item_delete inserts name from item table to the item_archive table, after a row from the table item is deleted.

CREATE TABLE item (
  id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(50) NOT NULL,
  quantity INT NOT NULL
);

CREATE TABLE item_archive (
  archive_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(50) NOT NULL
);

DELIMITER $$
CREATE  item_delete  ON item 
FOR EACH ROW
BEGIN
  INSERT INTO item_archive(name) VALUES ();
END;
$$
DELIMITER ;

See the example case for more details.

Easy  
7min
   


3. Registrations

MySQL Date Functions Public New

Consider the following DDL statement:

CREATE TABLE registrations (
  id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(50) NOT NULL,
  create_date DATE NOT NULL,
  last_activity DATE NOT NULL
);

Fill in the blanks so that the following select returns all registrations that were last active at least 30 days after being created.

SELECT name, create_date, last_activity FROM registrations
  WHERE  >= (, INTERVAL 30 DAY);

See the example case for more details.

Easy  
7min
   


If you feel ready, take one of our timed public MySQL Interview Questions tests:
  • MySQL and SQL Online Test (Easy)
  • PHP, MySQL, and SQL Online Test (Easy)
Not exactly what you are looking for? Go to our For Jobseekers section.