mysql - how to construct this query? -
i have table holds info videos on website. has fields id (primary key),title, series (int, foreign key constraint), , episode number. there table called "series" indexes video series. example, series "american dad" have series id of 1, , id column in series table same series column in videos table.
i trying create query that, when given video id, pulls title , video id of previous , next videos in series, e.g. if input id episode 5 american dad, info episodes 4 , 6.
i know how write query find series id when given video id, , know how write query find episodes of series when given series id. having trouble putting in 1 query, , limiting results preceding , following (based on episode number) of given video.
hopefully wasn't convoluted. appreciated!
if episode numbers sequential, can like
select ... (episode = :episode - 1 or episode = :episode + 1) , series = :series
Comments
Post a Comment