{"id":111782,"date":"2025-09-04T16:19:19","date_gmt":"2025-09-04T10:49:19","guid":{"rendered":"https:\/\/www.mygreatlearning.com\/blog\/?page_id=111782"},"modified":"2025-09-04T16:06:48","modified_gmt":"2025-09-04T10:36:48","slug":"mysql-exercise","status":"publish","type":"page","link":"https:\/\/www.mygreatlearning.com\/blog\/mysql-exercise\/","title":{"rendered":"MySQL Exercises"},"content":{"rendered":"\n<style>\n        \/* General styles *\/\n        .sql-input {\n\n            border-bottom: 1px dashed #9CA3AF !important;\n          \n        }\n        .sql-input:focus {\n            outline: none;\n            background-color: #E0E7FF;\n            border-bottom: 1px solid #3B82F6;\n        }\n\n        .sql-select {\n            font-family: monospace;\n            background-color: #F3F4F6;\n            border: 1px dashed #9CA3AF;\n            font-size: 0.875rem; \/* 14px *\/\n            color: #1D4ED8;\n            border-radius: 4px;\n            padding: 1px;\n        }\n        .sql-select:focus {\n            outline: none;\n            border: 1px solid #3B82F6;\n        }\n        \n        .sql-query-template {\n            background-color: #F9FAFB;\n            padding: 1rem;\n            border-radius: 0.375rem;\n            font-family: monospace;\n            font-size: 0.95rem;\n            color: #374151;\n            line-height: 1.6;\n        }\n\n        \/* CSS class for topic buttons for cleaner HTML and hover effects *\/\n        .topic-item-btn {\n            background-color: #FFFFFF;\n            padding: 1.5rem;\n            border-radius: 0.5rem;\n            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);\n            text-align: left;\n            width: 100%;\n            border: 1px solid #E5E7EB;\n            cursor: pointer;\n            transition: all 0.2s ease;\n        }\n        .topic-item-btn:hover {\n            transform: translateY(-3px);\n            box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);\n          background-color: white;\n          \n        }\n    <\/style>\n\n\n<div class=\"sql-ex-container\" style=\"font-family: sans-serif; background-color: #FFFFFF; color: #1F2937; max-width: 56rem; width: 100%; margin: 2rem auto; border-radius: 1rem; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); padding: 1.5rem;\">\n\n    <div id=\"sql-ex-topic-selection-view\">\n        <h1 style=\"font-size: 1.875rem; line-height: 2.25rem; font-weight: 700; text-align: center; color: #111827; margin-bottom: 0.5rem;\" style=\"font-size: 1.875rem; line-height: 2.25rem; font-weight: 700; text-align: center; color: #111827; margin-bottom: 0.5rem;\" id=\"mysql-practice-exercises\">MySQL Practice Exercises<\/h1>\n\t\t<p style=\"text-align: center; color: #6B7280;\">Practice 65+ MySQL with hands-on questions, and online exercises. Ideal for beginners and learners preparing for SQL interviews or real-world projects.<\/p>\n        <p style=\"text-align: center; color: #6B7280; margin-bottom: 2rem;\">Select a topic to start the exercise.<\/p>\n\n        <div id=\"sql-ex-topic-grid\" style=\"display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.5rem;\">\n            \n            <button class=\"topic-item-btn\" data-topic-key=\"SQLBasicsSELECT\">\n                <h3 style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" id=\"sql-basics-select\">SQL Basics & SELECT<\/h3>\n                <p style=\"color: #6B7280; margin: 0;\">5 exercise questions<\/p>\n            <\/button>\n            <button class=\"topic-item-btn\" data-topic-key=\"FilteringwithWHERE\">\n                <h3 style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" id=\"filtering-with-where\">Filtering with WHERE<\/h3>\n                <p style=\"color: #6B7280; margin: 0;\">5 exercise questions<\/p>\n            <\/button>\n            <button class=\"topic-item-btn\" data-topic-key=\"SortingLimiting\">\n                <h3 style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" id=\"sorting-limiting\">Sorting & Limiting<\/h3>\n                <p style=\"color: #6B7280; margin: 0;\">5 exercise questions<\/p>\n            <\/button>\n            <button class=\"topic-item-btn\" data-topic-key=\"AggregateFunctions\">\n                <h3 style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" id=\"aggregate-functions\">Aggregate Functions<\/h3>\n                <p style=\"color: #6B7280; margin: 0;\">5 exercise questions<\/p>\n            <\/button>\n            <button class=\"topic-item-btn\" data-topic-key=\"GroupingDatawithGROUPBY\">\n                <h3 style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" id=\"grouping-data-with-group-by\">Grouping Data with GROUP BY<\/h3>\n                <p style=\"color: #6B7280; margin: 0;\">5 exercise questions<\/p>\n            <\/button>\n            <button class=\"topic-item-btn\" data-topic-key=\"TableJoins\">\n                <h3 style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" id=\"table-joins\">Table Joins<\/h3>\n                <p style=\"color: #6B7280; margin: 0;\">5 exercise questions<\/p>\n            <\/button>\n            <button class=\"topic-item-btn\" data-topic-key=\"DataManipulationDML\">\n                <h3 style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" id=\"data-manipulation-dml\">Data Manipulation (DML)<\/h3>\n                <p style=\"color: #6B7280; margin: 0;\">5 exercise questions<\/p>\n            <\/button>\n            <button class=\"topic-item-btn\" data-topic-key=\"DataDefinitionDDL\">\n                <h3 style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" id=\"data-definition-ddl\">Data Definition (DDL)<\/h3>\n                <p style=\"color: #6B7280; margin: 0;\">5 exercise questions<\/p>\n            <\/button>\n            <button class=\"topic-item-btn\" data-topic-key=\"DataTypes\">\n                <h3 style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" id=\"data-types\">Data Types<\/h3>\n                <p style=\"color: #6B7280; margin: 0;\">5 exercise questions<\/p>\n            <\/button>\n            <button class=\"topic-item-btn\" data-topic-key=\"Constraints\">\n                <h3 style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" id=\"constraints\">Constraints<\/h3>\n                <p style=\"color: #6B7280; margin: 0;\">5 exercise questions<\/p>\n            <\/button>\n            <button class=\"topic-item-btn\" data-topic-key=\"Subqueries\">\n                <h3 style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" id=\"subqueries\">Subqueries<\/h3>\n                <p style=\"color: #6B7280; margin: 0;\">5 exercise questions<\/p>\n            <\/button>\n            <button class=\"topic-item-btn\" data-topic-key=\"Indexes\">\n                <h3 style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" id=\"indexes\">Indexes<\/h3>\n                <p style=\"color: #6B7280; margin: 0;\">5 exercise questions<\/p>\n            <\/button>\n            <button class=\"topic-item-btn\" data-topic-key=\"Views\">\n                <h3 style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" id=\"views\">Views<\/h3>\n                <p style=\"color: #6B7280; margin: 0;\">5 exercise questions<\/p>\n            <\/button>\n            <noscript>\n                <p style=\"text-align: center; background-color: #FEF2F2; color: #991B1B; padding: 1rem; border-radius: 0.5rem; grid-column: 1 \/ -1;\">\n                    The interactive exercises on this page require JavaScript. Please enable it in your browser to start practicing.\n                <\/p>\n            <\/noscript>\n        <\/div>\n    <\/div>\n\n    <div id=\"sql-ex-exercise-views-container\">\n        <\/div>\n\n<\/div>\n\n<script>\nconst sqlExercises = {\n    \"SQL Basics & SELECT\": [\n        { question: \"Select all columns and rows from a table named `customers`.\", template: [ \"SELECT \", { type: \"input\", size: 2, placeholder: \"...\" }, \" FROM \", { type: \"input\", size: 10, placeholder: \"table\" },\";\" ], solution: [\"*\", \"customers\"] },\n        { question: \"Select only the `name` and `email` columns from the `users` table.\", template: [ \"SELECT \", { type: \"input\", size: 12, placeholder: \"columns\" }, \" FROM users;\" ], solution: [\"name, email\"] },\n        { question: \"Which keyword is used to retrieve data from a database table?\", template: [ { type: \"select\", options: [\"SELECT\", \"GET\", \"FETCH\"] }, \" * FROM my_table;\" ], solution: [\"SELECT\"] },\n        { question: \"Write a query to select a specific static value: the number `100`.\", template: [ \"SELECT \", { type: \"input\", size: 4, placeholder: \"value\" }, \";\" ], solution: [\"100\"] },\n        { question: \"Which clause specifies the table from which to retrieve the data?\", template: [ \"SELECT * \", { type: \"select\", options: [\"FROM\", \"TABLE\", \"INTO\"] }, \" my_table;\" ], solution: [\"FROM\"] }\n    ],\n    \"Filtering with WHERE\": [\n        { question: \"From `products`, select all products with a `price` equal to `50`.\", template: [ \"SELECT * FROM products \", { type: \"input\", size: 6, placeholder: \"clause\" }, \" price = 50;\" ], solution: [\"WHERE\"] },\n        { question: \"Select employees from the `employees` table whose `department` is 'Sales'.\", template: [ \"SELECT * FROM employees WHERE department \", { type: \"input\", size: 2, placeholder: \"op\" }, \" 'Sales';\" ], solution: [\"=\"] },\n        { question: \"Find all products whose `name` starts with the letter 'S'.\", template: [ \"SELECT * FROM products WHERE name \", { type: \"select\", options: [\"LIKE\", \"STARTS\", \"BEGINS\"] }, \" 'S%';\" ], solution: [\"LIKE\"] },\n        { question: \"Select orders from `orders` with an `amount` greater than `1000`.\", template: [ \"SELECT * FROM orders WHERE amount \", { type: \"input\", size: 2, placeholder: \"op\" }, \" 1000;\" ], solution: [\">\"] },\n        { question: \"Find all users whose `country` is either 'USA' or 'Canada'.\", template: [ \"SELECT * FROM users WHERE country \", { type: \"input\", size: 3, placeholder: \"op\" }, \" ('USA', 'Canada');\" ], solution: [\"IN\"] }\n    ],\n    \"Sorting & Limiting\": [\n        { question: \"Select all products, ordered by `price` from lowest to highest.\", template: [ \"SELECT * FROM products \", { type: \"input\", size: 9, placeholder: \"clause\" }, \" price \", { type: \"select\", options: [\"ASC\", \"DESC\"] },\";\" ], solution: [\"ORDER BY\", \"ASC\"] },\n        { question: \"Select all customers, ordered by `signup_date` from newest to oldest.\", template: [ \"SELECT * FROM customers ORDER BY signup_date \", { type: \"select\", options: [\"ASC\", \"DESC\"] },\";\" ], solution: [\"DESC\"] },\n        { question: \"Which keyword is used to sort the result-set?\", template: [ \"SELECT * FROM products \", { type: \"input\", size: 9, placeholder: \"clause\" }, \" name;\" ], solution: [\"ORDER BY\"] },\n        { question: \"Retrieve only the top 5 most expensive products.\", template: [ \"SELECT * FROM products ORDER BY price DESC \", { type: \"input\", size: 6, placeholder: \"clause\" }, \" 5;\" ], solution: [\"LIMIT\"] },\n        { question: \"Which clause restricts the number of rows returned?\", template: [ \"SELECT * FROM products \", { type: \"input\", size: 6, placeholder: \"clause\" }, \" 10;\" ], solution: [\"LIMIT\"] }\n    ],\n    \"Aggregate Functions\": [\n        { question: \"Count the total number of records in the `customers` table.\", template: [ \"SELECT \", { type: \"input\", size: 8, placeholder: \"function\" }, \"(*) FROM customers;\" ], solution: [\"COUNT\"] },\n        { question: \"Find the total sum of all order `amounts`.\", template: [ \"SELECT \", { type: \"select\", options: [\"SUM\", \"TOTAL\", \"ADD\"] }, \"(amount) FROM orders;\" ], solution: [\"SUM\"] },\n        { question: \"Calculate the average `price` of all products.\", template: [ \"SELECT \", { type: \"input\", size: 4, placeholder: \"func\" }, \"(price) FROM products;\" ], solution: [\"AVG\"] },\n        { question: \"Find the price of the most expensive product.\", template: [ \"SELECT \", { type: \"input\", size: 4, placeholder: \"func\" }, \"(price) FROM products;\" ], solution: [\"MAX\"] },\n        { question: \"Find the earliest `order_date` from the `orders` table.\", template: [ \"SELECT \", { type: \"input\", size: 4, placeholder: \"func\" }, \"(order_date) FROM orders;\" ], solution: [\"MIN\"] }\n    ],\n    \"Grouping Data with GROUP BY\": [\n        { question: \"Count the number of employees in each `department`.\", template: [ \"SELECT department, COUNT(*) FROM employees \", { type: \"input\", size: 9, placeholder: \"clause\" }, \" department;\" ], solution: [\"GROUP BY\"] },\n        { question: \"Find the total sales `amount` for each `product_id`.\", template: [ \"SELECT product_id, SUM(amount) FROM sales GROUP BY \", { type: \"input\", size: 11, placeholder: \"column\" },\";\" ], solution: [\"product_id\"] },\n        { question: \"Which clause groups rows that have the same values into summary rows?\", template: [ \"SELECT category, AVG(price) FROM products \", { type: \"select\", options: [\"GROUP BY\", \"ORDER BY\", \"SUMMARIZE\"] }, \" category;\" ], solution: [\"GROUP BY\"] },\n        { question: \"Find departments that have more than 10 employees.\", template: [ \"SELECT department FROM employees GROUP BY department \", { type: \"input\", size: 7, placeholder: \"clause\" }, \" COUNT(*) > 10;\" ], solution: [\"HAVING\"] },\n        { question: \"What is the purpose of the `HAVING` clause?\", template: [ \"To filter groups based on \", { type: \"input\", size: 10, placeholder: \"aggregates\" }, \"\" ], solution: [\"aggregate functions\"] }\n    ],\n    \"Table Joins\": [\n        { question: \"Join `customers` and `orders` on the `customer_id` column.\", template: [ \"SELECT c.name, o.order_date FROM customers c \", { type: \"select\", options: [\"INNER JOIN\", \"LEFT JOIN\", \"CROSS JOIN\"] }, \" orders o \", { type: \"input\", size: 3, placeholder: \"keyword\" }, \" c.customer_id = o.customer_id;\" ], solution: [\"INNER JOIN\", \"ON\"] },\n        { question: \"What type of join returns all rows from the left table and matched rows from the right table?\", template: [ \"SELECT * FROM tableA \", { type: \"select\", options: [\"LEFT JOIN\", \"RIGHT JOIN\", \"INNER JOIN\"] }, \" tableB ON a.id = b.id;\" ], solution: [\"LEFT JOIN\"] },\n        { question: \"Get all customers, and any orders they might have placed.\", template: [ \"SELECT * FROM customers \", { type: \"input\", size: 10, placeholder: \"join type\" }, \" orders ON customers.customer_id = orders.customer_id;\" ], solution: [\"LEFT JOIN\"] },\n        { question: \"Which join returns records with matching values in both tables?\", template: [ \"SELECT * FROM tableA \", { type: \"input\", size: 10, placeholder: \"join type\" }, \" tableB ON a.id = b.id;\" ], solution: [\"INNER JOIN\"] },\n        { question: \"In a join, what keyword specifies the join condition?\", template: [ \"SELECT * FROM a JOIN b \", { type: \"select\", options: [\"ON\", \"WHERE\", \"WITH\"] }, \" a.id = b.id;\" ], solution: [\"ON\"] }\n    ],\n    \"Data Manipulation (DML)\": [\n        { question: \"Insert a new employee named 'John Doe' into the `employees` table.\", template: [ { type: \"input\", size: 12, placeholder: \"statement\" }, \" employees (name) \", { type: \"input\", size: 7, placeholder: \"keyword\" }, \" ('John Doe');\" ], solution: [\"INSERT INTO\", \"VALUES\"] },\n        { question: \"Update the `price` of product 101 to `25.50`.\", template: [ { type: \"input\", size: 7, placeholder: \"statement\" }, \" products \", { type: \"input\", size: 4, placeholder: \"keyword\" }, \" price = 25.50 WHERE product_id = 101;\" ], solution: [\"UPDATE\", \"SET\"] },\n        { question: \"Delete all orders where the `status` is 'cancelled'.\", template: [ { type: \"input\", size: 12, placeholder: \"statement\" }, \" orders WHERE status = 'cancelled';\" ], solution: [\"DELETE FROM\"] },\n        { question: \"What statement adds new rows of data to a table?\", template: [ { type: \"select\", options: [\"INSERT INTO\", \"ADD ROW\", \"CREATE DATA\"] } ], solution: [\"INSERT INTO\"] },\n        { question: \"What statement modifies existing records in a table?\", template: [ { type: \"select\", options: [\"UPDATE\", \"MODIFY\", \"CHANGE\"] } ], solution: [\"UPDATE\"] }\n    ],\n    \"Data Definition (DDL)\": [\n        { question: \"Create a table `students` with columns `id` (INT) and `name` (VARCHAR(100)).\", template: [ { type: \"input\", size: 13, placeholder: \"statement\" }, \" students (id INT, name VARCHAR(100));\" ], solution: [\"CREATE TABLE\"] },\n        { question: \"Add a new column `email` (VARCHAR(100)) to the `students` table.\", template: [ { type: \"input\", size: 12, placeholder: \"statement\" }, \" students \", { type: \"input\", size: 4, placeholder: \"keyword\" }, \" email VARCHAR(100);\" ], solution: [\"ALTER TABLE\", \"ADD\"] },\n        { question: \"Completely remove a table named `temp_data`.\", template: [ { type: \"input\", size: 11, placeholder: \"statement\" }, \" temp_data;\" ], solution: [\"DROP TABLE\"] },\n        { question: \"Which command modifies a table's structure?\", template: [ { type: \"select\", options: [\"ALTER TABLE\", \"MODIFY TABLE\", \"UPDATE TABLE\"] } ], solution: [\"ALTER TABLE\"] },\n        { question: \"What statement creates a new table?\", template: [ { type: \"select\", options: [\"CREATE TABLE\", \"NEW TABLE\", \"DEFINE TABLE\"] } ], solution: [\"CREATE TABLE\"] }\n    ],\n    \"Data Types\": [\n        { question: \"Which data type is best for a person's name (up to 50 chars)?\", template: [ { type: \"input\", size: 12, placeholder: \"type(size)\" } ], solution: [\"VARCHAR(50)\"] },\n        { question: \"What data type would you use for a whole number, like a user's ID?\", template: [ { type: \"select\", options: [\"INT\", \"NUMBER\", \"STRING\"] } ], solution: [\"INT\"] },\n        { question: \"Which data type is for a specific date without time?\", template: [ { type: \"input\", size: 5, placeholder: \"type\" } ], solution: [\"DATE\"] },\n        { question: \"What data type is ideal for monetary values like `19.99`?\", template: [ { type: \"input\", size: 15, placeholder: \"type(p, s)\" } ], solution: [\"DECIMAL(10, 2)\"] },\n        { question: \"Which data type stores large blocks of text?\", template: [ { type: \"select\", options: [\"TEXT\", \"BLOB\", \"STRING\"] } ], solution: [\"TEXT\"] }\n    ],\n    \"Constraints\": [\n        { question: \"Which constraint ensures a column cannot have a NULL value?\", template: [ \"email VARCHAR(100) \", { type: \"input\", size: 9, placeholder: \"constraint\" } ], solution: [\"NOT NULL\"] },\n        { question: \"What constraint uniquely identifies each record in a table?\", template: [ \"id INT \", { type: \"input\", size: 12, placeholder: \"constraint\" } ], solution: [\"PRIMARY KEY\"] },\n        { question: \"Add a primary key to the `id` column in an existing `products` table.\", template: [ \"ALTER TABLE products ADD \", { type: \"input\", size: 12, placeholder: \"constraint\" }, \" (id);\" ], solution: [\"PRIMARY KEY\"] },\n        { question: \"What constraint links two tables together?\", template: [ { type: \"select\", options: [\"FOREIGN KEY\", \"LINK KEY\", \"PARENT KEY\"] } ], solution: [\"FOREIGN KEY\"] },\n        { question: \"Which constraint ensures all values in a column are different?\", template: [ \"product_code VARCHAR(20) \", { type: \"input\", size: 7, placeholder: \"constraint\" } ], solution: [\"UNIQUE\"] }\n    ],\n    \"Subqueries\": [\n        { question: \"Find employees in the same department as 'Alice'.\", template: [ \"SELECT * FROM employees WHERE department = (\", { type: \"input\", size: 45, placeholder: \"subquery to get Alice's department\" }, \");\" ], solution: [\"SELECT department FROM employees WHERE name = 'Alice'\"] },\n        { question: \"Select products whose price is greater than the average price.\", template: [ \"SELECT * FROM products WHERE price > (SELECT \", { type: \"input\", size: 10, placeholder: \"aggregate\" }, \"(price) FROM products);\" ], solution: [\"AVG\"] },\n        { question: \"A subquery is a query nested inside another query.\", template: [ { type: \"select\", options: [\"True\", \"False\"] } ], solution: [\"True\"] },\n        { question: \"Find all customers who have placed at least one order.\", template: [ \"SELECT * FROM customers WHERE customer_id \", { type: \"select\", options: [\"IN\", \"EXISTS\", \"=\"] }, \" (SELECT customer_id FROM orders);\" ], solution: [\"IN\"] },\n        { question: \"Can a subquery return multiple rows when used with the `=` operator?\", template: [ { type: \"select\", options: [\"No\", \"Yes\"] } ], solution: [\"No\"] }\n    ],\n    \"Indexes\": [\n        { question: \"What is the primary purpose of an index?\", template: [ \"To \", { type: \"input\", size: 20, placeholder: \"speed up...\" }, \" of rows.\" ], solution: [\"speed up the retrieval\"] },\n        { question: \"Create an index `idx_lastname` on the `LastName` column of the `Persons` table.\", template: [ { type: \"input\", size: 13, placeholder: \"statement\" }, \" idx_lastname ON Persons (LastName);\" ], solution: [\"CREATE INDEX\"] },\n        { question: \"Does creating an index slow down `INSERT` and `UPDATE` operations?\", template: [ { type: \"select\", options: [\"Yes\", \"No\"] } ], solution: [\"Yes\"] },\n        { question: \"A good candidate for an index is a column frequently used in...\", template: [ { type: \"input\", size: 13, placeholder: \"a clause type\" } ], solution: [\"WHERE clauses\"] },\n        { question: \"How do you remove an index named `idx_lastname` from the `Persons` table?\", template: [ { type: \"input\", size: 11, placeholder: \"statement\" }, \" idx_lastname ON Persons;\" ], solution: [\"DROP INDEX\"] }\n    ],\n    \"Views\": [\n        { question: \"What is a view?\", template: [ \"A \", { type: \"input\", size: 14, placeholder: \"a ... table\" }, \" based on a SELECT statement.\" ], solution: [\"virtual table\"] },\n        { question: \"Create a view `US_Customers` for customers from the 'USA'.\", template: [ { type: \"input\", size: 12, placeholder: \"statement\" }, \" US_Customers AS SELECT * FROM Customers WHERE Country = 'USA';\" ], solution: [\"CREATE VIEW\"] },\n        { question: \"How would you query all data from a view named `US_Customers`?\", template: [ \"SELECT * FROM \", { type: \"input\", size: 13, placeholder: \"view name\" }, \";\" ], solution: [\"US_Customers\"] },\n        { question: \"Can you use DML statements (like UPDATE) on a simple, single-table view?\", template: [ { type: \"select\", options: [\"Yes, in many cases\", \"No, never\"] } ], solution: [\"Yes, in many cases\"] },\n        { question: \"How do you delete a view named `US_Customers`?\", template: [ { type: \"input\", size: 10, placeholder: \"statement\" }, \" US_Customers;\" ], solution: [\"DROP VIEW\"] }\n    ]\n};\n\ndocument.addEventListener('DOMContentLoaded', function() {\n    const topicSelectionView = document.getElementById('sql-ex-topic-selection-view');\n    const exerciseViewsContainer = document.getElementById('sql-ex-exercise-views-container');\n\n    \/\/ --- Utility Functions ---\n    function normalizeQuery(queryStr) {\n        if (typeof queryStr !== 'string') return '';\n        return queryStr.replace(\/\u201c|\u201d|\u2018|\u2019|\"\/g, \"'\").replace(\/;\/g, '').replace(\/\\s+\/g, ' ').trim().toUpperCase();\n    }\n    \n    \/\/ --- View Switching Logic ---\n    function showTopicView(topicKey) {\n        topicSelectionView.style.display = 'none';\n        document.querySelectorAll('.sql-ex-exercise-view').forEach(view => view.style.display = 'none');\n        const view = document.getElementById(`sql-ex-view-${topicKey}`);\n        if (view) {\n             view.style.display = 'block';\n        }\n    }\n\n    function showTopicSelection() {\n        topicSelectionView.style.display = 'block';\n        document.querySelectorAll('.sql-ex-exercise-view').forEach(view => view.style.display = 'none');\n    }\n    \n    \/\/ --- Initialization ---\n    function initialize() {\n        const topics = Object.keys(sqlExercises);\n\n        \/\/ Pre-build all Exercise Views (CSR part)\n        topics.forEach(topic => {\n            const topicKey = topic.replace(\/[^a-zA-Z0-9]\/g, '');\n            const questions = sqlExercises[topic];\n\n            let questionsHTML = '';\n            questions.forEach((q, qIndex) => {\n                let templateHTML = '';\n                let inputCounter = 0;\n                q.template.forEach(part => {\n                    if (typeof part === 'string') {\n                        templateHTML += `<span>${part.replace(\/<\/g, \"&lt;\").replace(\/>\/g, \"&gt;\")}<\/span>`;\n                    } else if (part.type === 'input') {\n                        templateHTML += `<input type=\"text\" class=\"sql-input\" id=\"sql-ex-answer-${topicKey}-${qIndex}-${inputCounter}\" size=\"${part.size || 10}\" placeholder=\"${part.placeholder || '...'}\">`;\n                        inputCounter++;\n                    } else if (part.type === 'select') {\n                        const optionsHTML = part.options.map(opt => `<option value=\"${opt}\">${opt}<\/option>`).join('');\n                        templateHTML += `<select class=\"sql-select\" id=\"sql-ex-answer-${topicKey}-${qIndex}-${inputCounter}\">${optionsHTML}<\/select>`;\n                        inputCounter++;\n                    }\n                });\n\n                questionsHTML += `\n                    <div style=\"border: 1px solid #E5E7EB; border-radius: 0.5rem;\">\n                        <div style=\"padding: 1rem; border-bottom: 1px solid #E5E7EB;\">\n                             <p style=\"font-weight: 500; margin:0; color: #374151;\">\n                                <span style=\"font-weight: 700; color: #111827;\">Question ${qIndex + 1}:<\/span> ${q.question}\n                            <\/p>\n                        <\/div>\n                        <div class=\"sql-query-template\">${templateHTML}<\/div>\n                        <div id=\"sql-ex-feedback-${topicKey}-${qIndex}\" style=\"margin-top: 0.5rem; padding: 0 1rem 0.5rem 1rem;\"><\/div>\n                    <\/div>\n                `;\n            });\n\n            const exerciseViewHTML = `\n                <div id=\"sql-ex-view-${topicKey}\" class=\"sql-ex-exercise-view\" style=\"display: none;\">\n                    <div style=\"display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; margin-bottom: 1.5rem; gap: 1rem;\">\n                        <h2 style=\"font-size: 1.5rem; line-height: 2rem; font-weight: 700; color: #111827; margin:0;\" style=\"font-size: 1.5rem; line-height: 2rem; font-weight: 700; color: #111827; margin:0;\" id=\"topic\">${topic}<\/h2>\n                        <button class=\"sql-ex-back-btn\" style=\"background-color: #E5E7EB; color: #374151; font-weight: 500; padding: 0.5rem 1rem; border-radius: 0.5rem; border: none; cursor: pointer;\" onmouseover=\"this.style.backgroundColor='#D1D5DB'\" onmouseout=\"this.style.backgroundColor='#E5E7EB'\">Back to Topics<\/button>\n                    <\/div>\n                    <div style=\"display: flex; flex-direction: column; gap: 1.5rem;\">${questionsHTML}<\/div>\n                    <div id=\"sql-ex-result-container-${topicKey}\" style=\"text-align: center; margin-top: 2rem;\"><\/div>\n                    <div style=\"text-align: center; margin-top: 1.5rem;\">\n                         <button class=\"sql-ex-check-answers-btn\" data-topic-key=\"${topicKey}\" data-topic-name=\"${topic}\" style=\"background-color: #2563EB; color: #FFFFFF; font-weight: 700; padding: 0.75rem 2rem; border-radius: 0.5rem; font-size: 1.125rem; border: none; cursor: pointer; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);\" onmouseover=\"this.style.backgroundColor='#1D4ED8'\" onmouseout=\"this.style.backgroundColor='#2563EB'\">Check Answers<\/button>\n                    <\/div>\n                <\/div>\n            `;\n            exerciseViewsContainer.innerHTML += exerciseViewHTML;\n        });\n\n        \/\/ --- Attach Event Listeners ---\n        document.querySelectorAll('.topic-item-btn').forEach(button => {\n            const topicKey = button.getAttribute('data-topic-key');\n            if (topicKey) {\n                button.addEventListener('click', () => showTopicView(topicKey));\n            }\n        });\n\n        document.querySelectorAll('.sql-ex-back-btn').forEach(btn => {\n            btn.addEventListener('click', showTopicSelection);\n        });\n\n        document.querySelectorAll('.sql-ex-check-answers-btn').forEach(btn => {\n            btn.addEventListener('click', (event) => {\n                const topicKey = event.currentTarget.getAttribute('data-topic-key');\n                const topicName = event.currentTarget.getAttribute('data-topic-name');\n                const questions = sqlExercises[topicName];\n                let correctCount = 0;\n\n                questions.forEach((q, qIndex) => {\n                    const feedbackContainer = document.getElementById(`sql-ex-feedback-${topicKey}-${qIndex}`);\n                    let isCorrect = true;\n                    let inputCounter = 0;\n                    \n                    let reconstructedUserQuery = \"\";\n                    q.template.forEach(part => {\n                        if (typeof part === 'string') {\n                            reconstructedUserQuery += part;\n                        } else {\n                            const userInputElem = document.getElementById(`sql-ex-answer-${topicKey}-${qIndex}-${inputCounter}`);\n                            reconstructedUserQuery += userInputElem.value;\n                            inputCounter++;\n                        }\n                    });\n\n                    \/\/ Normalizing whole reconstructed queries for comparison\n                    const normalizedUserAnswer = normalizeQuery(reconstructedUserQuery);\n                    \n                    let correctAnswerString = \"\";\n                     q.template.forEach((part, i) => {\n                        if (typeof part === 'string') {\n                            correctAnswerString += part;\n                        } else {\n                           correctAnswerString += q.solution[i - Math.floor(i\/2)];\n                        }\n                    });\n\n                    let fullCorrectAnswer = \"\";\n                    let solIdx = 0;\n                    q.template.forEach(part => {\n                        if (typeof part === 'string') {\n                            fullCorrectAnswer += part;\n                        } else {\n                            fullCorrectAnswer += q.solution[solIdx];\n                            solIdx++;\n                        }\n                    });\n                    \n                    if (normalizeQuery(fullCorrectAnswer) === normalizedUserAnswer) {\n                        correctCount++;\n                        feedbackContainer.innerHTML = `<p style=\"color: #16A34A; font-weight: 600; margin:0;\">\u2713 Correct!<\/p>`;\n                    } else {\n                        \/\/ Reconstruct the correct answer string for display\n                        let correctAnswerHTML = '';\n                        let solutionCounter = 0;\n                        q.template.forEach(part => {\n                            if (typeof part === 'string') {\n                                correctAnswerHTML += `<span>${part.replace(\/<\/g, \"&lt;\").replace(\/>\/g, \"&gt;\")}<\/span>`;\n                            } else {\n                                correctAnswerHTML += `<strong style=\"color: #166534;\">${q.solution[solutionCounter]}<\/strong>`;\n                                solutionCounter++;\n                            }\n                        });\n\n                        feedbackContainer.innerHTML = `\n                            <p style=\"color: #DC2626; font-weight: 600; margin:0;\">\u2717 Incorrect.<\/p>\n                            <p style=\"color: #4B5563; margin-top: 0.25rem; margin-bottom: 0.25rem;\">The correct query is:<\/p>\n                            <pre style=\"background-color: #F0FDF4; color: #1F2937; padding: 0.75rem; border-radius: 0.375rem; font-size: 0.875rem; margin-top: 0.25rem; font-family: monospace; white-space: pre-wrap; word-wrap: break-word;\"><code>${correctAnswerHTML}<\/code><\/pre>\n                        `;\n                    }\n                });\n\n                const resultContainer = document.getElementById(`sql-ex-result-container-${topicKey}`);\n                resultContainer.innerHTML = `\n                    <p style=\"font-size: 1.25rem; font-weight: 700;\">You answered ${correctCount} out of ${questions.length} questions correctly.<\/p>\n                    <p style=\"color: #6B7280; margin-top: 0.25rem;\">Review the feedback above and feel free to try again!<\/p>\n                `;\n            });\n        });\n    }\n\n    \/\/ Run the initialization\n    initialize();\n});\n<\/script>\n\n\n\n<div class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\">\n<p>Also Check:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.mygreatlearning.com\/blog\/sql-commands\/\">SQL Commands<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.mygreatlearning.com\/blog\/sql-editor-tool\/\">Online SQL Compiler<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.mygreatlearning.com\/blog\/hands-on-sql-projects\/\">Top SQL Projects<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.mygreatlearning.com\/blog\/sql-interview-questions\/\">SQL Interview Questions and Answers<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.mygreatlearning.com\/blog\/mysql-tutorial\/\">MySQL Tutorial<\/a><\/li>\n<\/ul>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Practice MySQL with hands-on questions, queries, and online exercises. Ideal for beginners and learners preparing for SQL interviews or real-world projects.<\/p>\n","protected":false},"author":41,"featured_media":111787,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"full-width-container","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"disabled","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[25860],"tags":[36844],"class_list":["post-111782","page","type-page","status-publish","has-post-thumbnail","hentry","category-software","tag-sql"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>MySQL Practice Questions and Online Exercises<\/title>\n<meta name=\"description\" content=\"Practice MySQL with hands-on questions, queries, and online exercises. Ideal for beginners and learners preparing for SQL interviews or real-world projects.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mygreatlearning.com\/blog\/mysql-exercise\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MySQL Exercises\" \/>\n<meta property=\"og:description\" content=\"Practice MySQL with hands-on questions, queries, and online exercises. Ideal for beginners and learners preparing for SQL interviews or real-world projects.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mygreatlearning.com\/blog\/mysql-exercise\/\" \/>\n<meta property=\"og:site_name\" content=\"Great Learning Blog: Free Resources what Matters to shape your Career!\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/GreatLearningOfficial\/\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/mysql-exercise.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1408\" \/>\n\t<meta property=\"og:image:height\" content=\"768\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@Great_Learning\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/mysql-exercise\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/mysql-exercise\\\/\"},\"author\":{\"name\":\"Great Learning Editorial Team\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\"},\"headline\":\"MySQL Exercises\",\"datePublished\":\"2025-09-04T10:49:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/mysql-exercise\\\/\"},\"wordCount\":121,\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/mysql-exercise\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/09\\\/mysql-exercise.webp\",\"keywords\":[\"sql\"],\"articleSection\":[\"IT\\\/Software Development\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/mysql-exercise\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/mysql-exercise\\\/\",\"name\":\"MySQL Practice Questions and Online Exercises\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/mysql-exercise\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/mysql-exercise\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/09\\\/mysql-exercise.webp\",\"datePublished\":\"2025-09-04T10:49:19+00:00\",\"description\":\"Practice MySQL with hands-on questions, queries, and online exercises. Ideal for beginners and learners preparing for SQL interviews or real-world projects.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/mysql-exercise\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/mysql-exercise\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/mysql-exercise\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/09\\\/mysql-exercise.webp\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/09\\\/mysql-exercise.webp\",\"width\":1408,\"height\":768,\"caption\":\"MySQL Exercise\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/mysql-exercise\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MySQL Exercises\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"name\":\"Great Learning Blog\",\"description\":\"Learn, Upskill &amp; Career Development Guide and Resources\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"alternateName\":\"Great Learning\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\",\"name\":\"Great Learning\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"width\":900,\"height\":900,\"caption\":\"Great Learning\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/GreatLearningOfficial\\\/\",\"https:\\\/\\\/x.com\\\/Great_Learning\",\"https:\\\/\\\/www.instagram.com\\\/greatlearningofficial\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/in.pinterest.com\\\/greatlearning12\\\/\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/beaconelearning\\\/\"],\"description\":\"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.\",\"email\":\"info@mygreatlearning.com\",\"legalName\":\"Great Learning Education Services Pvt. Ltd\",\"foundingDate\":\"2013-11-29\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"1001\",\"maxValue\":\"5000\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\",\"name\":\"Great Learning Editorial Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"caption\":\"Great Learning Editorial Team\"},\"description\":\"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.\",\"sameAs\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/\",\"https:\\\/\\\/in.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/Great_Learning\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCObs0kLIrDjX2LLSybqNaEA\"],\"award\":[\"Best EdTech Company of the Year 2024\",\"Education Economictimes Outstanding Education\\\/Edtech Solution Provider of the Year 2024\",\"Leading E-learning Platform 2024\"],\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/author\\\/greatlearning\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"MySQL Practice Questions and Online Exercises","description":"Practice MySQL with hands-on questions, queries, and online exercises. Ideal for beginners and learners preparing for SQL interviews or real-world projects.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.mygreatlearning.com\/blog\/mysql-exercise\/","og_locale":"en_US","og_type":"article","og_title":"MySQL Exercises","og_description":"Practice MySQL with hands-on questions, queries, and online exercises. Ideal for beginners and learners preparing for SQL interviews or real-world projects.","og_url":"https:\/\/www.mygreatlearning.com\/blog\/mysql-exercise\/","og_site_name":"Great Learning Blog: Free Resources what Matters to shape your Career!","article_publisher":"https:\/\/www.facebook.com\/GreatLearningOfficial\/","og_image":[{"width":1408,"height":768,"url":"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/mysql-exercise.webp","type":"image\/webp"}],"twitter_card":"summary_large_image","twitter_site":"@Great_Learning","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.mygreatlearning.com\/blog\/mysql-exercise\/#article","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/mysql-exercise\/"},"author":{"name":"Great Learning Editorial Team","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad"},"headline":"MySQL Exercises","datePublished":"2025-09-04T10:49:19+00:00","mainEntityOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/mysql-exercise\/"},"wordCount":121,"publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/mysql-exercise\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/mysql-exercise.webp","keywords":["sql"],"articleSection":["IT\/Software Development"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.mygreatlearning.com\/blog\/mysql-exercise\/","url":"https:\/\/www.mygreatlearning.com\/blog\/mysql-exercise\/","name":"MySQL Practice Questions and Online Exercises","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/mysql-exercise\/#primaryimage"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/mysql-exercise\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/mysql-exercise.webp","datePublished":"2025-09-04T10:49:19+00:00","description":"Practice MySQL with hands-on questions, queries, and online exercises. Ideal for beginners and learners preparing for SQL interviews or real-world projects.","breadcrumb":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/mysql-exercise\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mygreatlearning.com\/blog\/mysql-exercise\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/mysql-exercise\/#primaryimage","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/mysql-exercise.webp","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/mysql-exercise.webp","width":1408,"height":768,"caption":"MySQL Exercise"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mygreatlearning.com\/blog\/mysql-exercise\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/www.mygreatlearning.com\/blog\/"},{"@type":"ListItem","position":2,"name":"MySQL Exercises"}]},{"@type":"WebSite","@id":"https:\/\/www.mygreatlearning.com\/blog\/#website","url":"https:\/\/www.mygreatlearning.com\/blog\/","name":"Great Learning Blog","description":"Learn, Upskill &amp; Career Development Guide and Resources","publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"alternateName":"Great Learning","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mygreatlearning.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization","name":"Great Learning","url":"https:\/\/www.mygreatlearning.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","width":900,"height":900,"caption":"Great Learning"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/GreatLearningOfficial\/","https:\/\/x.com\/Great_Learning","https:\/\/www.instagram.com\/greatlearningofficial\/","https:\/\/www.linkedin.com\/school\/great-learning\/","https:\/\/in.pinterest.com\/greatlearning12\/","https:\/\/www.youtube.com\/user\/beaconelearning\/"],"description":"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.","email":"info@mygreatlearning.com","legalName":"Great Learning Education Services Pvt. Ltd","foundingDate":"2013-11-29","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"1001","maxValue":"5000"}},{"@type":"Person","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad","name":"Great Learning Editorial Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","caption":"Great Learning Editorial Team"},"description":"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.","sameAs":["https:\/\/www.mygreatlearning.com\/","https:\/\/in.linkedin.com\/school\/great-learning\/","https:\/\/x.com\/https:\/\/twitter.com\/Great_Learning","https:\/\/www.youtube.com\/channel\/UCObs0kLIrDjX2LLSybqNaEA"],"award":["Best EdTech Company of the Year 2024","Education Economictimes Outstanding Education\/Edtech Solution Provider of the Year 2024","Leading E-learning Platform 2024"],"url":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"}]}},"uagb_featured_image_src":{"full":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/mysql-exercise.webp",1408,768,false],"thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/mysql-exercise-150x150.webp",150,150,true],"medium":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/mysql-exercise-300x164.webp",300,164,true],"medium_large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/mysql-exercise-768x419.webp",768,419,true],"large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/mysql-exercise-1024x559.webp",1024,559,true],"1536x1536":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/mysql-exercise.webp",1408,768,false],"2048x2048":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/mysql-exercise.webp",1408,768,false],"web-stories-poster-portrait":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/mysql-exercise-640x768.webp",640,768,true],"web-stories-publisher-logo":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/mysql-exercise-96x96.webp",96,96,true],"web-stories-thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/mysql-exercise-150x82.webp",150,82,true]},"uagb_author_info":{"display_name":"Great Learning Editorial Team","author_link":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"},"uagb_comment_info":0,"uagb_excerpt":"Practice MySQL with hands-on questions, queries, and online exercises. Ideal for beginners and learners preparing for SQL interviews or real-world projects.","_links":{"self":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/pages\/111782","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/comments?post=111782"}],"version-history":[{"count":9,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/pages\/111782\/revisions"}],"predecessor-version":[{"id":111789,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/pages\/111782\/revisions\/111789"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media\/111787"}],"wp:attachment":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media?parent=111782"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/categories?post=111782"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/tags?post=111782"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}