A
A
Albert Ushakov2020-06-04 21:09:20
PHP
Albert Ushakov, 2020-06-04 21:09:20

How to group the same categories, take their id and search for products on them?

An example like on aliexpress, several stores in one, but their categories and products are grouped into a single list on the main page. Unfortunately, each store can have the same categories, because of this I entered a dead end.

Here is a request to display all categories:
This displays the main categories in the sub_category column, the id of the category in which the subcategory belongs is indicated, if the main one is 0. Server response:
SELECT * FROM bot_shop_category WHERE hide = 0

Продукты
Одежда
Одежда
итд...

How 1 to make grouping of the same categories for output?
How 2 on another page, for example, to save these IDs and display subcategories and products of this category?

I really need help on the first question, the second one I think I myself will figure out how to understand how to do the first, please, who did this, could you throw a code or an article where there is a description of such requests?
I myself am weak in cql, I can only do basic queries, without difficult conditions ((

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GAS-ART, 2020-06-04
@Gavr_Gavr

To group equal values, use the DISTINCT
SELECT DISTINCT * FROM ... specifier.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question