MySQL Forums
Forum List  »  Newbie

Re: subselect fails
Posted by: Brian Case
Date: June 22, 2018 12:31PM

Before I change the foreign key name in the billing table to something else, am I missing a syntax error?

SELECT w.*, b.* FROM project p JOIN workunit w ON p.projectid = w.projectid LEFT JOIN billing b ON w.workunitid = b.workunitid WHERE p.projectid = 9 ORDER BY w.type, w.workunitid ASC";

Result is that
(1) Though workunitid exists in both workunit (w.) and billing (b.) tables, the sql result set shows it only once.
(2) If there is no corresponding workunitid in b., the sql result shows workunitid as NULL (which I guess means the the result set is picking up the b.workunitid, not the w.workunitid.)

I have tried changing the select to read "SELECT w.workunitid, w.*, b.* ..."). Same result.

The number of records in the result set is correct, as are all the workunit and billing fields. Just the workunitid is corrupted.

Options: ReplyQuote


Subject
Written By
Posted
June 19, 2018 10:27AM
June 19, 2018 12:01PM
June 19, 2018 02:20PM
June 19, 2018 02:45PM
Re: subselect fails
June 22, 2018 12:31PM
June 22, 2018 03:09PM
June 22, 2018 03:19PM
June 19, 2018 02:30PM


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.