Thanks, Jeremy.

On Tuesday, February 22, 2022 at 9:48:16 AM UTC-6 Jeremy Evans wrote:

> On Tue, Feb 22, 2022 at 7:19 AM cra...@gmail.com <cra...@gmail.com> wrote:
>
>> I'm trying to explicitly specify columns from two related models:
>> dataset = TableA
>>     .where(table_a_column_a: 'foo')
>>     .select(:table_a_column_b,:ambiguous_column)
>>     .join(:table_b, table_a_id: :table_b_id)
>>     .where(table_b_column_a: 'bar')
>>     .select_more(:table_b_column_b)
>>
> This syntax doesn't work.
>>
>> How do I specify:
>>
>>    - table_b.table_b_column_b 
>>
>> Sequel[:table_b][:column_b]
>
>>
>>    - table_a.ambiguous_column, which exists in both tables
>>
>> Sequel[:table_a][:ambiguous_column]
>
> Note that if you are selecting the same column name from multiple tables, 
> you'll probably want to alias:
>
> Sequel[:table_a][:column_b].as(:a_b)
> Sequel[:table_b][:column_b].as(:b_b)
>
> The documentation goes into more detail about this: 
> http://sequel.jeremyevans.net/rdoc/files/doc/sql_rdoc.html#label-Identifiers
>
> Thanks,
> Jeremy
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/fe1ce607-0dd9-42a8-8a0c-ab2108d356ecn%40googlegroups.com.

Reply via email to