Hi.
I searched MySQL manual but I stil don't know how a JOIN works. I would
like to avoid diging into sources so I'm posting this mail.
I have two tables:
- a HUGE table having a row ID_keywords
- a SMALL table with keywords and columns ID_keywords and keyword_name
I have to select some rows from a HUGE table that have certain keywords
(there can be 10.000 or even more results). I can acomplish this in two
ways:
1. SELECT <some_rows_from_h> FROM
HUGE h LEFT JOIN SMALL s
ON h.ID_keywords=s.ID_keywords
WHERE (s.keyword_name='name1') OR (s.keyword_name='name2') OR ...
GROUP BY ...
2. First get ID_keywords for <name1>, <name2>,... and then do:
SELECT <some_rows> FROM
HUGE
WHERE (ID_keywords=<returnes_ID1>) OR (ID_keywords=<returnes_ID2>) OR
...
GROUP BY ...
And now the question:
- How does the JOIN works? Does it first get IDs from the second table
(SMALL)
and then use them for the WHERE clause?
- Which query from the above examples will be faster (on my test data I
get
every time the response that the query finished in 0.0s , but I'm now
working
only on a small set of data and not on read data which aren't available
to
me right now)?
- Is there some diference if I made a join on a join? E.g.:
SELECT <some_rows> FROM
table1 LEFT JOIN table2
ON <something>
LEFT JOIN table3
ON <something_else>
WHERE <blahblah>
GROUP BY ...
Thanks and regards,
Dezo
---------------------------------------------------------------------
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