Thanks again Jeremy, 
I had poorly asked the question, but your answer put me on the right track. 
The documentation is fantastic. It took me some time to get my head around 
the concept "DataSet". But it now all works like a charm. 
Best greetings,
Thiebo

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

> On Sat, May 28, 2022 at 2:00 PM Thiebo <thiebald...@gmail.com> 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 sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/a6929de4-8497-4961-8982-e75223ea7ecfn%40googlegroups.com.

Reply via email to