Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> select count po where, osCommerce
raczkowski1
post
Post #1





Grupa: Zarejestrowani
Postów: 35
Pomógł: 0
Dołączył: 26.07.2007

Ostrzeżenie: (0%)
-----


Witam
Próbuję wyświetlić tylko te kategorie produktów, które zawierają jakieś towary.
Mam takie zapytanie:
  1. SELECT c.categories_id, cd.categories_name, c.parent_id
  2. FROM categories c, categories_description cd
  3. WHERE c.parent_id = '0' AND c.categories_id = cd.categories_id AND cd.language_id='1' AND
  4. (SELECT count(p.products_id) AS total
  5. FROM products_description pd, products p
  6. LEFT JOIN manufacturers m ON p.manufacturers_id = m.manufacturers_id
  7. LEFT JOIN specials s ON p.products_id = s.products_id, products_to_categories p2c WHERE p.products_status = '1' AND p.products_id = p2c.products_id AND pd.products_id = p2c.products_id AND pd.language_id = '1' AND (p2c.categories_id IN (SELECT categories_id
  8. FROM `categories` cc WHERE c.parent_id = c.categories_id) OR p2c.categories_id = c.categories_id) AND p.products_quantity >= '0') >0
  9.  
  10. ORDER BY cd.categories_name

Zwraca mi listę z pominięciem dwóch kategorii, ale jak dam
  1. [...]OR p2c.categories_id = c.categories_id) AND p.products_quantity >= '0') > -1
  2.  
  3. ORDER BY cd.categories_name


To mi wyświetla wszystkie kategorie.

Co tu jest nie tak??



A znowu to zapytanie działa:
  1. SELECT c.categories_id, cd.categories_name, c.parent_id ,
  2. (SELECT count(cc.categories_id)
  3. FROM categories cc, categories_description ccd WHERE cc.parent_id = c.categories_id AND cc.categories_id = ccd.categories_id AND ccd.language_id='1'
  4. )AS total
  5. FROM categories c, categories_description cd
  6. WHERE c.parent_id = '0' AND c.categories_id = cd.categories_id AND cd.language_id='1' AND
  7. (SELECT count(cc.categories_id)
  8. FROM categories cc, categories_description ccd WHERE cc.parent_id = c.categories_id AND cc.categories_id = ccd.categories_id AND ccd.language_id='1'
  9. )>0
  10. ORDER BY cd.categories_name

Czyżby tamto je za długie...:/

Z góry dzięki za pomoc.
Pozdrawiam

Ten post edytował raczkowski1 15.06.2011, 14:29:30


--------------------
Dariusz Raczkowski

www.atrium-pc.pl
www.e-pozyczka.one.pl
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 06:04