Mysql
 sql >> Database >  >> RDS >> Mysql

MYSQL:query per ottenere l'ID video precedente e successivo?

Penso che potresti usare qualcosa come:

SELECT * 
  FROM videos AS c 
 WHERE (VideoId = (SELECT MAX(VideoId) FROM videos WHERE VideoId < c.VideoId AND IsActive = 1)
    OR  VideoId = (SELECT MIN(VideoId) FROM videos WHERE VideoId > c.VideoId AND IsActive = 1))