Skip to content
Advertisement

getting id filtered from a query and using it in another query

I’ve queried user_invitations.inviter_id with filter I want which is:

From here I am trying to use only inviter_id to get id in another table called user (i.e. want to get user_id that match inviter_id I’ve just got above)

I’ve tried doing inner joing

no luck, I thought about using subquery

but in most inner query it I cannot find out a way to return inviter_id after filtering by invited_cnt >= 52. How can I achieve this, is it not possible since to use having invited_cnt >= 52 we need aggreate count?

I’ve looked at some resources: Select id from one query and use it in another

but none of them seem to deal with aggregate.

Advertisement

Answer

If I understood your question, this query should give you the user_id from user that matched the inviter_id

If you are expecting only one user_id, then I think this should work. Although it would be nice if you included your table structure plus some sample data and expected output

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement