Complex query
Posted by: Musca Ilie
Date: October 23, 2007 07:11AM

Hello, i`m trying since morning to get a result.

I have a users table and a table which holds products for selling..
Each user has the option to mark several products as 'special'.

i need a list which contains the name of the 'special' products which belong to the first 5 users who have the highest number of products.

users(user_id,user_name)
products(product_name,product_special,user_id)

select count(user_id),user_name as no
from users
natural join products
order by no desc
limit 5 -> this query shows the first 5 users which have the most products

select product_name,user_name
natural join users
where product_special='1' -> this query shows all the 'special' products

I need the result of the two queries combined somehow.

thanks!



Edited 1 time(s). Last edit at 10/23/2007 07:22AM by Musca Ilie.

Options: ReplyQuote


Subject
Written By
Posted
Complex query
October 23, 2007 07:11AM
October 23, 2007 02:02PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.