MySQL Forums
Forum List  »  General

Re: cross joining 3 tables
Posted by: Peter Brawley
Date: September 07, 2015 12:20PM

A Cross Join is not just a join across multiple tables. It's a join that deliberately omits key specification, so it returns all logically possible combinations of rows from the joined tables.

Adopt a convention about underscores in the names of columns that end with ID, then stick to your convention, otherwise you condemn yourself and whoever else has to work with your database to endless typo corrections.

If business_users send or receive packages, the relationship is probably one-many rather than many-one, in which case packages would need a foreign key into business_users, rather than the other way round.

Your spec is for an ordinary Inner Join; is this what you mean?

select u.name,u.lastname,t.user_type
from users u
join business_users b on u.user_id=b.crid
join buz_usertype t on b.bus_user_type=t.type_id
where u.lastname like 'Doe%';

Options: ReplyQuote


Subject
Written By
Posted
September 07, 2015 07:37AM
Re: cross joining 3 tables
September 07, 2015 12:20PM
September 16, 2015 10:55AM


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.