I have the following scenario: I am trying to pass result of one query to another , In this case I am trying to pass view_id in another query since this are ids they are unique and cant be duplicate in any case .
select view_id from view where view_query_id = "18711987173"
select queue_id from queue where queue_view = view_id
`
I saw some examples and I tried executing them something like as
select view_id from view where view_query_id = "18711987173 exists (select queue_id from queue where queue_view = view.view_id)
But surely this didnt helped 🙂
2
Answers
You can use a common table expression
This should work regardless of what relationship is between those tables. You can replace the
JOIN
byWHERE..IN
, but this way seems cleaner and takes care if the no. of values inIN
becomes too large.Use table expression