Thanks a lot Jeremy, 

Le dimanche 29 mai 2022 à 01:15:00 UTC+2, Jeremy Evans a écrit :

> On Sat, May 28, 2022 at 2:00 PM Thiebo <[email protected]> wrote:
>
>> I have one table "data"
>>
>>    Column       | 
>> ---------------------+
>>  id                    |
>>  account_id    |
>>  categorie_id  |
>>  amount          |
>>
>>
>> And a table "categories"
>>
>>    Column       |
>> ---------------------+
>>  id                    |
>>  name             |
>>
>> I want to "translate" this SQL query into Sequel:
>>
>>  SELECT data.id, data.amount, data.name, data.data, categories.name as 
>> categorie FROM data RIGHT OUTER JOIN categories ON(categories.id = 
>> data.categorie_id);
>>
>
>  DB[:data].
>   right_outer_join(:categories, id: :categorie_id).
>   select{[data[:id], data[:amount], data[:name], data[:data], 
> categories[:name].as(:categorie)]}
>
> I can't find in the documentation (
>> https://sequel.jeremyevans.net/rdoc/files/doc/querying_rdoc.html) how to 
>> select specific fields in a join query and how to select "as". 
>>
>
> Aliasing is mentioned in other places in the documentation:
>
>
> https://sequel.jeremyevans.net/rdoc/files/README_rdoc.html#label-Expression+aliases
>
> https://sequel.jeremyevans.net/rdoc/files/doc/cheat_sheet_rdoc.html#label-Aliasing
> https://sequel.jeremyevans.net/rdoc/files/doc/sql_rdoc.html#label-Aliasing
>
> 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/094e08c5-bdb6-4816-9561-5d6bae465581n%40googlegroups.com.

Reply via email to