Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT t.*,
- (SELECT TOP 1 url
- FROM [dbo].[tbl_images] i INNER JOIN
- [dbo].[tbl_images_links] l ON i.id = l.id_image
- WHERE obj_type = 'news' AND l.obj_id = t .id
- ORDER BY main_image DESC)
- AS image_url,
- (SELECT TOP 1 outsource_code
- FROM [dbo].[tbl_videos] AS v
- INNER JOIN [dbo].[tbl_videos_links] vl ON v.id = vl.id_video
- WHERE vl.obj_type = 'news' AND vl.obj_id = t.id)
- AS video_code,
- (SELECT TOP 1 a.date_insert AS video_date_insert
- FROM [dbo].[tbl_videos] AS a
- INNER JOIN [dbo].[tbl_videos_links] b ON a.id = b.id_video
- WHERE b.obj_type = 'news' AND b.obj_id = t.id)
- AS video_date_insert
- FROM dbo.tbl_news AS t
- WHERE id_theme IS NOT NULL
- ORDER BY id
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement