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

chris_smith_51
on
Medium Priority
158 Views
Last Modified: 2012-05-06
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

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.

Ask the Experts

Author

Commented:
dammit i thought i'd tried that lol
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

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

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.