Results 1 to 5 of 5
Thread: SQL query filter help needed
Apr 4, 2008, 01:04 #1
- Join Date
- Oct 2006
- 0 Post(s)
- 0 Thread(s)
SQL query filter help needed
I'm having this tables for products, products orders and products accesses (downloads) and I want to build a filter query. Everything works fine for the products table but when the query gets a little more complicated and, for example, I want to select only the products that have more than 1 orders or more than 1 accesses nothing happens....the filter doesn't work. I'll just paste the query here...hope there is someone to light this up a little for me.
SELECT COUNT( products_accesses.ID ) AS accesses, COUNT( products_orders.ID ) AS orders, products . * FROM `products` LEFT JOIN products_accesses ON ( products.ID = products_accesses.prod_id ) LEFT JOIN products_orders ON ( products.ID = products_orders.prod_id ) WHERE ( SELECT COUNT( products_accesses.ID ) FROM products_accesses LEFT JOIN products ON ( products.ID = products_accesses.prod_id ) ) > '1' AND ( SELECT COUNT( products_orders.ID ) FROM products_orders LEFT JOIN products ON ( products.ID = products_orders.prod_id ) ) > '1' GROUP BY products.ID
There's no error or anything like that...just an invalid filter.