MySQL Forums
Forum List  »  General

Re: Query - multiple joins won't return any records
Posted by: Rick James
Date: February 15, 2015 07:59PM

Sorry, I missed a point:
The FieldID defines the table (1=divisions; 2=teams)
Which means that FieldID does need to be in the ON, not the WHERE.

Anyway, it is not 'normal' to put all the many-to-many relationships in a single table (as Peter pointed out). Please split `Relations` into two (or more) tables, one for each N-N relation. And use consistent naming (DivisionID, not ValID) so that the JOINs are easy to validate. (This is for my sake as a helper, and I'll bet it will keep you out of trouble eventually.)

After that, please present the CREATE TABLEs and the SELECT, plus EXPLAIN SELECT...

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.