On Sat, May 28, 2022 at 2:00 PM Thiebo <thiebald.crem...@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/CADGZSSe6HMahMTNp-R4qjuGgPm47wAysEGzXuBftHfXM1BrfqA%40mail.gmail.com.