Next/Prev buttons for nodes based on nodereference field By using this tutorial http://blog.urbaninsight.com/2011/09/12/adding-pager-navigation-nodes-drupal-7 I have created next/prev buttons for my images. 

But as I have a lot of galleries and I need to filter images not only by node type but also by node reference field value.

The machine name of my field is field_pers_gallery and in phpmyadmin it is assigned to a particular gallery by field_pers_gallery_nid.

I'm note good at creating db query, could anybody help with any advices?
I don't know if you managed to get your pager working yet, but I've just modified a piece of code to create a pager based on node reference. You're free to use it as you see fit. You can go to my blog to see it:

http://www.visionarymedia.nl/blog/drupal-pager-based-node-reference