# How to join for where clause but not select a table

**URL:** https://discourse.diesel.rs/t/how-to-join-for-where-clause-but-not-select-a-table/152
**Category:** Uncategorized
**Created:** [June 2, 2020, 8:58am UTC](https://discourse.diesel.rs/t/how-to-join-for-where-clause-but-not-select-a-table/152 "2020-06-02T08:58:40Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![alextan](https://avatars.discourse-cdn.com/v4/letter/a/fbc32d/32.png) [@alextan](https://discourse.diesel.rs/u/alextan)
#### Post date: [June 2, 2020, 8:58am UTC](https://discourse.diesel.rs/t/how-to-join-for-where-clause-but-not-select-a-table/152/1 "2020-06-02T08:58:40Z")

</div>

I’m trying to do a join on a table so that I can filter records but not actually selecting from that table. Here’s the example where it’s still selecting from the joined table. I assume you can manually specify the select using tuples but is there a way to do this using a Queryable struct instead?

```
  let (existing_excerpt, _) = source_items::table
    .inner_join(sources::table)
    .filter(source_items::id.eq(json.original_excerpt_id))
    .filter(sources::user_id.eq(jwt.user_id))
    .first::<(SourceItem, Source)>(&db.0)
    .map_err(PostError::LoadSourceID)?;

```

Any advice? Thanks.

---

<div class="post-metadata">

### Author: ![weiznich](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.diesel.rs/weiznich/32/64_2.png) [@weiznich](https://discourse.diesel.rs/u/weiznich)
#### Post date: [June 2, 2020, 9:59am UTC](https://discourse.diesel.rs/t/how-to-join-for-where-clause-but-not-select-a-table/152/2 "2020-06-02T09:59:07Z")

</div>

Just use a [explicit select clause](https://docs.rs/diesel/1.4.4/diesel/query_dsl/trait.QueryDsl.html#method.select) to specify which columns you want to select. Those need to match your struct that implements `Queryable`. If you want to select all columns of a given table you can do something like `.select((sources::column_a, sources_column_b, …))` or `.select(sources::all_columns)`
