MySQL Mastery Quiz: Test Your Database Knowledge Quiz

  1. Basic Data Retrieval

    What SQL statement is used to retrieve all columns from a table called 'users'?

    1. SELECT * FROM users;
    2. GET * FROM users;
    3. FETCH ALL users;
    4. RETRIEVE users ALL;
    5. SELECT ALL FROM users;
  2. Filtering Data

    Which clause would you use in an SQL query to filter results based on a specific condition?

    1. WHERE
    2. FILTER
    3. HAVING
    4. WHICH
    5. CONDITION
  3. Database Connection

    Which method is commonly used in PHP to securely connect to a MySQL database and prevent SQL Injection?

    1. Using prepared statements with PDO
    2. Building queries with string concatenation
    3. Using eval() to construct queries
    4. Directly inserting variables into SQL strings
    5. Connecting without authentication
  4. Primary Keys

    What is the primary key used for in a MySQL table?

    1. To uniquely identify each row
    2. To encrypt table data
    3. To store index position
    4. To define a foreign table
    5. To increase query speed only
  5. UPDATE Statement Syntax

    Which of the following is the correct syntax to update the 'email' column to 'user@example.com' for the user with id 5 in a 'users' table?

    1. UPDATE users SET email = 'user@example.com' WHERE id = 5;
    2. MODIFY users email = 'user@example.com' WHEN id = 5;
    3. CHANGE users TO email = 'user@example.com' IF id = 5;
    4. UPDATE users ON email = 'user@example.com' WHERE id = 5;
    5. UPDATE users SET email: 'user@example.com' WHERE id == 5;
  6. SQL Injection Prevention

    How can you best prevent SQL Injection attacks in your database queries?

    1. By using parameterized queries
    2. By hashing all user data
    3. By removing all user input
    4. By disabling database logging
    5. By setting a strong password
  7. Aggregate Functions

    Which SQL function returns the total number of rows in a table, including those with NULL values?

    1. COUNT(*)
    2. SUM(*)
    3. TOTAL()
    4. ADDALL(*)
    5. COUNT_ROWS()
  8. Sorting Results

    What keyword would you use to sort the results of a query in ascending order based on the 'created_at' column?

    1. ORDER BY created_at ASC
    2. SORT BASED created_at UP
    3. SORT BY created_at ASCENDING
    4. ORDER ON created_at ALPHABET
    5. ARRANGE created_at ASC
  9. NULL Value Checking

    How do you check if the column 'email' is NULL in a WHERE clause?

    1. WHERE email IS NULL
    2. WHERE email = NULL
    3. WHERE email EQUALS NULL
    4. WHERE email ISNOT SET
    5. WHERE NULL email
  10. Limiting Results

    Which clause is used in a SELECT statement to limit the number of rows returned?

    1. LIMIT
    2. ROWLIMIT
    3. FETCH
    4. TOP
    5. MAXROWS