let (a, b) = diesel::alias!(schema::script_tag as a, schema::script_tag as b);
let query = a
.filter(a.field(schema::script_tag::dsl::script_id).eq(strategy_id))
.select(
b.filter(
b.field(schema::script_tag::dsl::tag_id).eq(a.field(schema::script_tag::dsl::tag_id)),
).filter(b.field(schema::script_tag::dsl::is_output).eq(false))
.count()
.single_value(),
);
Which produces this:
SELECT (
SELECT COUNT(*)
FROM script_tag AS b
WHERE ((b.tag_id = a.tag_id) AND (b.is_output = false))
LIMIT 1)
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?