This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 23rd, 2013  |  syntax: None  |  size: 1.87 KB  |  views: 24  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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)
clone this paste RAW Paste Data