I have the following scenario: Tables:
Video (id, url)
VideoCategoria (id, id_video, id_categoria)
Categoria (id, descricao)
I need to get the last 120 categories that have received videos. At the same cursor I wanted the following fields:
(Video.Url, Categoria.descricao)
Only you can not repeat the url
of the video, for example, if a single video enters two different categories, then category 1 and 2 are coming with the same Url
.
I've been given a solution here using cursor
and doing loops
until I find another video, I tried to do everything in SQL, but I can not do it, does anyone know if it's possible?
I'm using id
of table Video_Categoria
to get the newest records.
UPDATE:
Scheme created in the SqlFiddle as requested in the comment.