MySQL Forums
Forum List  »  Newbie

Re: Simple join-query
Posted by: Peter Brawley
Date: May 28, 2014 12:25PM

1. Drop comma join syntax in favour of explicit join syntax, it's easier to develop, debug and maintain, and less buggy.

2. For readability, use aliases.

3. The logic of your join on email is fishy: if there is a users row with an id matching invitations.host X but an email matching invitations.host Y, your query will show that email belonging to host X---surely not what you had in mind. Isn't this what you mean?

select i.Name, i.Email, i.Lingo, u.name as Host, u.email as users_email
from j2012_ub_invitations i
join j2012_users u on i.Host = u.id;

Options: ReplyQuote


Subject
Written By
Posted
May 28, 2014 12:21AM
Re: Simple join-query
May 28, 2014 12:25PM
May 29, 2014 02:18AM


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.