What are the two primary types of joins?
Why are aliases often used with joins?
Why is it considered often necessary and at least a best practice to use the table.column syntax in joins?
What impact does the order of tables used have on an outer join?
How do you create a self-join?
SELECT m1.message_id,m1.subject, m2.subject AS Reply FROM messages AS m1 LEFT JOIN messages AS m2 ON
m1.message_id=m2.parent_id where m1.parent_id=0
+------------+-------------------------------+------------------------+
| message_id | subject | Reply |
+------------+-------------------------------+------------------------+
| 1 | Question about normalization. | NULL |
| 2 | Database Design | Database Design |
| 4 | Database Design | NULL |
| 5 | PHP Errors | PHP Errors |
| 9 | Chicago Bulls | Chicago Bulls |
| 11 | CSS Resources | CSS Resources |
| 13 | HTML vs. XHTML | HTML vs. XHTML |
| 15 | Why? | Why? Why? Why? |
| 16 | Dynamic HTML using PHP | Dynamic HTML using PHP |
+------------+-------------------------------+------------------------+
9 rows in set (0.00 sec)
mysql> select message_id,parent_id,forum_id,subject from messages;
+------------+-----------+----------+-----------------------------------------+
| message_id | parent_id | forum_id | subject |
+------------+-----------+----------+-----------------------------------------+
| 1 | 0 | 1 | Question about normalization. |
| 2 | 0 | 1 | Database Design |
| 3 | 2 | 1 | Database Design |
| 4 | 0 | 1 | Database Design |
| 5 | 0 | 2 | PHP Errors |
| 6 | 5 | 2 | PHP Errors |
| 7 | 6 | 2 | PHP Errors |
| 8 | 7 | 2 | PHP Errors |
| 9 | 0 | 3 | Chicago Bulls |
| 10 | 9 | 3 | Chicago Bulls |
| 11 | 0 | 5 | CSS Resources |
| 12 | 11 | 5 | CSS Resources |
| 13 | 0 | 4 | HTML vs. XHTML |
| 14 | 13 | 4 | HTML vs. XHTML |
| 15 | 0 | 6 | Why? |
| 16 | 0 | 2 | Dynamic HTML using PHP |
| 17 | 16 | 2 | Dynamic HTML using PHP |
| 18 | 17 | 2 | Dynamic HTML using PHP, still not clear |
| 19 | 18 | 2 | Dynamic HTML using PHP, clearer? |
| 20 | 15 | 6 | Why? Why? Why? |
| 21 | 20 | 6 | Because |
+------------+-----------+----------+-----------------------------------------+
21 rows in set (0.00 sec)
mysql> SELECT m1.message_id AS P_id, m1.subject, m2.subject AS Reply, m2.message_id AS R_id FROM messages AS m1 LEFT JOIN messages AS m2 ON m1.message_id=m2.parent_id WHERE m1.parent_id=0;
+------+-------------------------------+------------------------+------+
| P_id | subject | Reply | R_id |
+------+-------------------------------+------------------------+------+
| 1 | Question about normalization. | NULL | NULL |
| 2 | Database Design | Database Design | 3 |
| 4 | Database Design | NULL | NULL |
| 5 | PHP Errors | PHP Errors | 6 |
| 9 | Chicago Bulls | Chicago Bulls | 10 |
| 11 | CSS Resources | CSS Resources | 12 |
| 13 | HTML vs. XHTML | HTML vs. XHTML | 14 |
| 15 | Why? | Why? Why? Why? | 20 |
| 16 | Dynamic HTML using PHP | Dynamic HTML using PHP | 17 |
+------+-------------------------------+------------------------+------+
9 rows in set (0.00 sec)
What are the aggregate functions?
What impact does the DISTINCT keyword have on an aggregate function? What impact does GROUP BY have on an aggregate function?
What kind of index is required in order to perform FULLTEXT searches? What type of storage engine?
What impact does it have when you conclude a SELECT query with \G instead of a semicolon in the mysql client?
How do IN BOOLEAN MODE FULLTEXT searches differ from standard FULLTEXT searches?
An IN BOOLEAN MODE FULLTEXT search is more sophisticated than a normal FULLTEXT search in that it has a number of operators that tweak how each keyword is treated. You can use the '+' operator to indicate that a word must be present in a search. The '-' operator can indicate words that must NOT be present. The '>' operator will increase a word's importance, whereas the '<' operator will decrease the importance of a word, affecting the rankings of the matching records. The asterisk is used as a wildcard character
, the tilde '~' is used to reduce the ranking if a search term is present. Several other differences compared to a normal FULLTEXT search:
mysql> SELECT subject, body, MATCH(body, subject) AGAINST('*HTML >XHTML' IN BOOLEAN MODE) AS R FROM messages WHERE MATCH(body, subject) AGAINST('*HTML >XHTML' IN BOOLEAN MODE) ORDER BY R DESC\G
*************************** 1. row ***************************
subject: HTML vs. XHTML
body: What are the differences between HTML and XHTML?
R: 2.5
*************************** 2. row ***************************
subject: HTML vs. XHTML
body: XHTML is a cross between HTML and XML. The differences are largely syntactic. Blah, blah, blah...
R: 2.5
*************************** 3. row ***************************
subject: CSS Resources
body: Read Elizabeth Castro's excellent book on (X)HTML and CSS. Or search Google on "CSS".
R: 1
*************************** 4. row ***************************
subject: Dynamic HTML using PHP
body: Can I use PHP to dynamically generate HTML on the fly? Thanks...
R: 1
*************************** 5. row ***************************
subject: Dynamic HTML using PHP
body: You most certainly can.
R: 1
*************************** 6. row ***************************
subject: Dynamic HTML using PHP, still not clear
body: Um, how?
R: 1
*************************** 7. row ***************************
subject: Dynamic HTML using PHP, clearer?
body: I think what Larry is trying to say is that you should buy and read his book.
R: 1
7 rows in set (0.00 sec)
mysql>
What commands can you use to improve a table’s performance?
One command that helps to maintain the table and remove unnecessary overhead is the OPTIMIZE command. This should be used after a table has been changed with the ALTER command, or after many DELETE queries have been run.
A second command is the ANALYZE command, which updates the indexes on the table.
How do you examine the efficiency of a query?
You can use the EXPLAIN query command, which gives an indication of how MySQL will run a query. This gives details on the way a query will be conducted, perhaps indicating where an index should be added, where a table should be modified, etc.
Why doesn’t the forum database support transactions?
How do you begin a transaction? How do you undo the effects of a transaction in progress? How do you make the effects of the current transaction permanent?
What kind of column type is required to store the output from the AES_ENCRYPT( ) function?
What are the important criteria for the salt used in the encryption process?