Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2013
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. SELECT `parent`.`id_sklep_kategoria`,
  2. (COUNT(sklep_kategorie_produkty.id_sklep_produkt)) AS `ilosc`
  3. FROM `sklep_kategorie` AS `node`
  4. INNER JOIN `sklep_kategorie` AS `parent`
  5. INNER JOIN `sklep_kategorie_produkty`
  6. WHERE (node.lft BETWEEN parent.lft AND parent.rght)
  7. AND (node.id_sklep_kategoria = sklep_kategorie_produkty.id_sklep_kategoria)
  8. AND (node.visible = 1)
  9. GROUP BY `parent`.`id_sklep_kategoria`
  10.  
  11. "id_sklep_kategoria"(category id),
  12. "id_sklep_produkt"(product id)
  13.  
  14. +----+-------------+--------------------------+------+--------------------+--------------------+---------+-----------------------------------+------+------------------------------------------------+
  15. | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
  16. +----+-------------+--------------------------+------+--------------------+--------------------+---------+-----------------------------------+------+------------------------------------------------+
  17. | 1 | SIMPLE | node | ALL | PRIMARY,lft | NULL | NULL | NULL | 983 | Using where; Using temporary; Using filesort |
  18. | 1 | SIMPLE | sklep_kategorie_produkty | ref | id_sklep_kategoria | id_sklep_kategoria | 4 | c2_330_1.node.id_sklep_kategoria | 9 | Using index |
  19. | 1 | SIMPLE | parent | ALL | lft,rght | NULL | NULL | NULL | 983 | Range checked for each record (index map: 0x6) |
  20. +----+-------------+--------------------------+------+--------------------+--------------------+---------+-----------------------------------+------+------------------------------------------------+
  21. 3 rows in set (0.00 sec)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement