sql,query

Which way is faster?

Way 1:

SELECT *
FROM users
LEFT JOIN boardAdmins ON boardAdmins.userId = users.id
LEFT JOIN boardMembers ON boardMembers.userId = users.id
WHERE id = 5;

Way 2:

SELECT * FROM users WHERE id = 5;

SELECT * FROM boardAdmins WHERE userId = 5;

SELECT * FROM boardMembers WHERE userId = 5;

(Note that all of these SELECT statements only retrieve a single row,
since the primary keys are users.id, boardAdmins.userId and
boardMembers.userId.)

The second way probably is going to have more latency between the
client and the database server.

---------------------------------------------------------------------
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