Advertisement
Guest User

Untitled

a guest
Dec 1st, 2015
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. SELECT t.*,
  2. (SELECT TOP 1 url
  3. FROM [dbo].[tbl_images] i INNER JOIN
  4. [dbo].[tbl_images_links] l ON i.id = l.id_image
  5. WHERE obj_type = 'news' AND l.obj_id = t .id
  6. ORDER BY main_image DESC)
  7. AS image_url,
  8. (SELECT TOP 1 outsource_code
  9. FROM [dbo].[tbl_videos] AS v
  10. INNER JOIN [dbo].[tbl_videos_links] vl ON v.id = vl.id_video
  11. WHERE vl.obj_type = 'news' AND vl.obj_id = t.id)
  12. AS video_code,
  13. (SELECT TOP 1 a.date_insert AS video_date_insert
  14. FROM [dbo].[tbl_videos] AS a
  15. INNER JOIN [dbo].[tbl_videos_links] b ON a.id = b.id_video
  16. WHERE b.obj_type = 'news' AND b.obj_id = t.id)
  17. AS video_date_insert
  18. FROM dbo.tbl_news AS t
  19. WHERE id_theme IS NOT NULL
  20. ORDER BY id
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement