We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

# Getting sql values from nested statement

on
Medium Priority
158 Views
Hi, could someone please show me how to get the first "video_name" and "video_owner" specified by the main SELECT at the places shown by #?

SELECT video_name, video_owner FROM (SELECT * FROM requests WHERE username != 'David.young' AND video_owner != 'David.young') AS q1 WHERE EXISTS (SELECT * FROM videos WHERE name = video_name AND username = video_owner AND private = false) AND NOT EXISTS (SELECT * FROM requests WHERE username = 'David.young' AND video_name =  ##### AND video_owner = #####) GROUP BY video_name, video_owner ORDER BY COUNT(video_name) DESC LIMIT 1;
Comment
Watch Question

## View Solution Only

Senior .Net Developer
CERTIFIED EXPERT
Commented:
wouldn't that be

q1.video_name and q1.video_owner?

SELECT Q1.video_name, Q1.video_owner FROM (SELECT * FROM requests WHERE username != 'David.young' AND video_owner != 'David.young') AS q1 WHERE EXISTS (SELECT * FROM videos WHERE name = video_name AND username = video_owner AND private = false) AND NOT EXISTS (SELECT * FROM requests WHERE username = 'David.young' AND video_name =  ##### AND video_owner = #####) GROUP BY video_name, video_owner ORDER BY COUNT(video_name) DESC LIMIT 1;

Not the solution you were looking for? Getting a personalized solution is easy.

Commented:
dammit i thought i'd tried that lol
##### Thanks for using Experts Exchange.

• View three pieces of content (articles, solutions, posts, and videos)
• Ask the experts questions (counted toward content limit)
• Customize your dashboard and profile