MYSQL-Anfrage aus beiden Tabellen mit FIND_IN_SET

Ich habe zwei Tabellen (MySQL):

  1. table_products: //cid (text) - Komma-getrennte Liste Kategorien //id (int11)

    id   cid
    1    1,2,3        
    2    5,21,8
    3    2,4,15
  2. table_categories

    id   name   parent        
    1    Cat1   0      
    2    Cat2   0
    3    Cat3   0
    4    Cat4   0  

Dies ist mein Wunsch:

SELECT `id`, `name`, `parent`
FROM `table_categories`
ORDER BY `parent` ASC, `id` ASC;

Wie kann ich die Anfrage vor, und auch die Anzahl der Produkte in jeder Kategorie (von table_products).
Möglicherweise verwenden (FIND_IN_SET).

InformationsquelleAutor user889349 | 2013-04-17
Schreibe einen Kommentar