# 2 Quick SQL Questions: Paginate Conditions and Adding to Val

**URL:** <https://www.ruby-forum.com/t/2-quick-sql-questions-paginate-conditions-and-adding-to-val/104612>\
**Category:** Rails\
**Created:** [May 20, 2007, 6:12pm UTC](https://www.ruby-forum.com/t/2-quick-sql-questions-paginate-conditions-and-adding-to-val/104612 "2007-05-20T18:12:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 20, 2007, 6:12pm UTC](https://www.ruby-forum.com/t/2-quick-sql-questions-paginate-conditions-and-adding-to-val/104612/1 "2007-05-20T18:12:07Z")

</div>

I have 2 quick SQL questions that all my googling couldnt come up with  
an answer

1. Paginate results based on 2 conditions

I currently have sorthelper sorting based on title/author. I’d like  
the option to select based on 3 genres then be able to sort that  
through those results by title. I haven’t be able to see how to handle  
sorting with a variable condition. (codes below

1. How to add to current value

How would I add to a current value in my table?

value = value.current + value.new

def upcoming

items\_per\_page = 8  
@total = Albums.count  
@sorter = SortingHelper::Sorter.new self, %w(artist album  
votes\_count date created\_at), @params[‘sort’], @params[‘order’],  
‘created\_at’, ‘asc’  
@albums\_pages, @albums = paginate :albumss, :order =\>  
@sorter.to\_sql, :per\_page =\> items\_per\_page

render :layout =\> ‘albums\_upcoming’

end
