5

2 つのテーブル (MySQL) があります。

  1. table_products: // cid (テキスト) - カンマ区切りのカテゴリ リスト // 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  
    

これは私の要求です:

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

上記のリクエストを実行し、各カテゴリの製品数を (table_products から) 取得するにはどうすればよいですか。(FIND_IN_SET) を使用している可能性があります。

4

1 に答える 1