I got my query to work...

However, this query is going to be used a LOT, so I want to make sure it's
completely optimized. I have keys on all fields that I should...here's the
query I'm using:

select m.member_id, t.num_questions, r.score FROM members as m, trivia as t,
results as r WHERE t.trivia_id = 16 AND r.trivia_id = t.trivia_id AND
m.username = 'daren_cotter' AND m.member_id = r.member_id;

Using explain:

explain select m.member_id, t.num_questions, r.score FROM members as m,
trivia as t, results as r WHERE t.trivia_id = 16 AND r.trivia_id =
t.trivia_id AND m.username = 'daren_cotter' AND m.member_id = r.member_id;
+-------+--------+--------------------------------------------------+-------
--+---------+-------+------+-------+
| table | type   | possible_keys                                    | key
| key_len | ref   | rows | Extra |
+-------+--------+--------------------------------------------------+-------
--+---------+-------+------+-------+
| r     | system | PRIMARY,results_trivia_id_member_id              | NULL
|    NULL | NULL  |    1 |       |
| m     | const  | PRIMARY,members_username_unique,members_username |
PRIMARY |       3 | const |    1 |       |
| t     | const  | PRIMARY                                          |
PRIMARY |       2 | const |    1 |       |
+-------+--------+--------------------------------------------------+-------
--+---------+-------+------+-------+
3 rows in set (0.00 sec)

Can someone please tell me if this is optimized?

TIA,



Daren Cotter


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to