On Monday, August 27, 2018 at 11:53:28 AM UTC-7, Joseph Kowalski wrote:
>
> Is there a sequel way to do updates using a FROM clause to update multiple 
> specific rows with specific data per row?
>
> The raw sql example from Stack Overflow (
> https://stackoverflow.com/questions/18797608/update-multiple-rows-in-same-query-using-postgresql#18799497)
>  
> looks like this:
>
> update test as t set
>     column_a = c.column_afrom (values
>     ('123', 1),
>     ('345', 2)  ) as c(column_b, column_a) where c.column_b = t.column_b;
>
>
DB.from(Sequel[:test].as(:t), DB.values([['123', 1], ['345', 2]]).as(:c, 
[:column_b, :column_a])) .
  where{c[:column_b] =~ t[:column_b]}.
  update(:column_a=>Sequel[:c][:column_a])

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