On Tuesday, October 24, 2017 at 7:12:48 AM UTC-7, Rob Sharp wrote:
>
> Hi group,
>
> I'm not 100% sure of the terminology here, but how can I join my existing 
> dataset using the equivalent of what I have below?
>
> SELECT fruits.*, map_fruit_a, map_fruit_b FROM fruits
>   JOIN (
>     VALUES(
>       'pineapple',
>       'banane', 
>       'apple', 
>       'pomme'
>     )
>   ) AS mapped_fruits(
>     fruit_a,
>     map_fruit_a,
>     fruit_b,
>     map_fruit_b
>   )
>   ON mapped_fruits.fruit_a = fruits.name
>
> Any help appreciated!
>

Since this is a single row, a select query that returns one row should work:

 DB[:fruits].
  join(DB.select('pineapple', 'banane', 'apple', 
'pomme').as(:mapped_fruits, [:fruit_a, :map_fruit_a, :fruit_b, 
:map_fruit_b]), :fruit_a=>:name).
  select_all(:fruits).
  select_append(:map_fruit_a, :map_fruit_b)

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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to