PHP Level 3, SQL

6 Questions | Total Attempts: 235

SettingsSettingsSettings
Please wait...
PHP Quizzes & Trivia

This isn't a PHP quiz as much as it is a simple SQL quiz. Passing this test indicates a basic understanding of SQL, and how it's used with PHP. We use MySQL syntax.


Questions and Answers
  • 1. 
    If you're in an SQL command line environment (like "mysql"), which SQL statement would be useful if you wanted to add two numbers together, like 540 + 232?  With what word would your SQL statement begin?
    • A. 

      SELECT

    • B. 

      SUM()

    • C. 

      PRINT

    • D. 

      ADD

  • 2. 
    Adding an index to a table will cause some things to speed up, and other things to slow down.  What are its main effects you usually have to consider?
    • A. 

      Speeds up updates, slows down selects.

    • B. 

      Speeds up selects, slows down inserts.

    • C. 

      Slows down updates, speeds up inserts.

    • D. 

      Slows down deletions and truncations, speeds up selects.

  • 3. 
    The rows of SQL result sets are most similar to which PHP data structure?
    • A. 

      Associative arrays.

    • B. 

      Objects.

    • C. 

      Numerically indexed arrays.

    • D. 

      Packed binary strings.

    • E. 

      Serialized array structures.

  • 4. 
    You have a query that can return thousands of rows.  What MySQL statement will cause your query to return fewer rows?
    • A. 

      GROUP

    • B. 

      LIMIT

    • C. 

      OFFSET

    • D. 

      JOIN

    • E. 

      TOP

  • 5. 
    You need to implement yet another user and group system.  The rule is that a user can belong to only one group.  What's a typical way to create a report of all the users for a specific group (for example, group_id=1).
    • A. 

      Select * from users where group_id=1

    • B. 

      Select * from groups where groups.id=1

    • C. 

      Select * from groups join users on users.group_id=groups.id WHERE users.group_id=1

    • D. 

      Select * from users join groups on users.group_id=groups.id WHERE group.id=1

  • 6. 
    What is wrong with this SQL INSERT statement?INSERT INTO tbl (name, group_id) VALUES (joe, 10)
    • A. 

      "joe" requires single quotes

    • B. 

      The group_id value needs single quotes.

    • C. 

      Tbl is not a valid name for a table.

    • D. 

      `name` and `group_id` need backticks.