Help for this page
CREATE TABLE images ( id INT ... ,next_id INT ,other_columns_here );
SELECT * FROM images WHERE ( (id=?) OR (next_id=?) OR (prev_id=?) );