I work hierarchical categories and products table for my project.
categories table structure:
ID - PARENT - TITLE
1 - 0 - Computer
1 - 0 - Phones
...
Categories table count of row 25107.
Product Table structure
ID - CAT - TITLE
1 - 1 - Product Name is here
I want current category and sub categories for list product.
echo $subcats = categoryChild(0);
Output is: 64198,18355,18356,95623,90504,6118,90505,6117,90506,90507,6119,6120,90508,90509,90510,90511,6103,90512,90513,90514,90515,142686,142688,142790,90516,6105,90517,90518,90519,90520,90521,91691,91692,92189,92190,92312,92313,95618,95619,95620,95621,95622,142684,142690,142692,142694,142696,142698,142700,3596
And I'm using this output MySQL IN statment. Finally generate this SQL query:
SELECT * FROM products WHERE cat IN (64198,18355,18356,95623,90504,6118,90505,6117,90506,90507,6119,6120,90508,90509,90510,90511,6103,90512,90513,90514,90515,142686,142688,142790,90516,6105,90517,90518,90519,90520,90521,91691,91692,92189,92190,92312,92313,95618,95619,95620,95621,95622,142684,142690,142692,142694,142696,142698,142700,3596)
This query is very slow... Please help me.