I have a question. I have a table of categories:
CREATE TABLE 'categorias' (
'id' int(10) UNSIGNED NOT NULL,
'parent_id' int(10) DEFAULT NULL,
'lft' int(10) DEFAULT NULL,
'rght' int(10) DEFAULT NULL,
'nome' varchar(255) DEFAULT NULL,
'publicado' int(11) NOT NULL DEFAULT '0',
'icon' varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
And a product table:
CREATE TABLE 'produtos' (
'id' int(11) NOT NULL,
'titulo' varchar(255) DEFAULT NULL,
'data' date DEFAULT NULL,
'categoria_id' int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Where products.category_id is a foreign key to the category table. The category table has categories and subcategories, where categories.parent_id refers to a category.id to indicate that it is the child of the same.
I need to export the product table with a JOIN taking 3 first levels of the categories, and I do not know which function to use for the best fit.
Result should be: PRODUCT NAME - NAME CATEGORY LEVEL 1 - NAME CATEGORY LEVEL 2 - NAME CATEGORY LEVEL 3 - DATE
Can you help me?