Need help creating a query with diesel

I want to return the number of rows in the same table that has the same tag_id and is_output=false.
I think this is the the query I want in SQL:

select t.*, (
	select count(*)
	from script_tag
	where tag_id=t.tag_id and is_output=false
from script_tag as t
where script_id = 1

I don't understand how to nest a subquery or what I need to do to expose the each row from the outer query to the inner?

I've come up with this:

let (a, b) = diesel::alias!(schema::script_tag as a, schema::script_tag as b);
let query = a

Which produces this:

	FROM script_tag AS b
	WHERE ((b.tag_id = a.tag_id) AND (b.is_output = false))
FROM script_tag AS a
WHERE (a.script_id = 2)

I just need to get that first a.*, in right after the first select - how can I do that?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.