?
Solved

Getting sql values from nested statement

Posted on 2009-02-18
2
Medium Priority
?
149 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;
0
Comment
Question by:chris_smith_51
2 Comments
 
LVL 41

Accepted Solution

by:
Kyle Abrahams earned 500 total points
ID: 23671607
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;
0
 
LVL 2

Author Closing Comment

by:chris_smith_51
ID: 31548304
dammit i thought i'd tried that lol
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question