How to properly join a table with a raw subquery? #2459
Unanswered
anthonyma94
asked this question in
Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have 2 tables, one that holds device data, and the other stores status history of the devices:
This is the SQL I researched to retrieve the latest status from all unique devices:
My problem comes when I'm integrating this to Objection JS:
There's 2 issues I'm having. First, the query doesn't work with
withGraphFetched()
, onlywithGraphJoined()
. This is the error if I runIOTDevice.query().withGraphFetched("statusRelationship")
:Second, even with
withGraphJoined()
, I can't use any functions that reference an ambiguous column. For example, this is the error message if I runIOTDevice.query().withGraphJoined("statusRelationship")
:I'd like to be able to run the latter function without having to reference the table. Any suggestions on how I can fix this?
Beta Was this translation helpful? Give feedback.
All reactions