MySQL Forums
Forum List  »  Newbie

Re: Query Help
Posted by: Shawn Green
Date: November 24, 2017 03:50PM

You will need to link the Y table twice from the X table to get those separate D values.

Try this:

SELECT x.*, y1.d, y2.d
FROM x
INNER JOIN y as y1
ON x.x1 = y1.d
INNER JOIN y as y2
ON x.x2 = y2.d
WHERE y1.d <> y2.d;

This query will be slow until you add an index to your Y table.

Yours,
--
Shawn Green
MySQL Senior Principal Technical Support Engineer
Oracle USA, Inc. - Integrated Cloud Applications & Platform Services
Office: Blountville, TN

Become certified in MySQL! Visit https://www.mysql.com/certification/ for details.

Options: ReplyQuote


Subject
Written By
Posted
November 24, 2017 11:01AM
November 24, 2017 01:40PM
Re: Query Help
November 24, 2017 03:50PM


Sorry, only registered users may post in this forum.

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.