How will you eliminate duplicate values from a query result in MySQL?

Опубликовано: 21 Март 2026
на канале: Knowledge Powerhouse
4,730
18

Q. How will you eliminate duplicate values from a query result in MySQL?
MySQL provides DISTINCT keyword to remove duplicates from a query result. With DISTINCT keyword, a value will be displayed only once.

Eg. SELECT DISTINCT NAME FROM EMPLOYEE;

This query will return each name in Employee table only once.

Q. How will you get the size of data in a MySQL table?
In MySQL, there is an information_schema that contains the TABLES object. We can run a query on TABLES to get the size of data in a table.

Eg. If we have a table named EMPLOYEE, the query to get the size of data will be as follows:

SELECT table_name "Table Name",sum( data_length + index_length ) / 1024 / 1024 "Table Size (MB)"
FROM information_schema.TABLES
WHERE table_name='EMPLOYEE';


Learn more MySQL interview questions, join our popular MySQL Interview Questions Preparation Course with more than 50 questions for $10 only today!!

https://www.udemy.com/mysql-interview...

Source: http://www.knowledgepowerhouse.com/vi...