M
M
Mikhail M2017-05-13 16:36:17
PHP
Mikhail M, 2017-05-13 16:36:17

How to display the answer for two fields at once in sql query?

Hello. There is a problem with the sql query .. the query itself is large, but the bottom line is that I have a category directory, and a product that is in a category.
It turns out such a relationship that the product in T1 (goods) corresponds to the number of the category and subcategory, by the number of the category and subcategory in T2 (connection with the name), the number of the name in T3 (name) is determined.
And when linking, I can display only the column of names corresponding to either the category or subcategory, or the name of the subcategory, and the name of the category is only a number from T2.
Naturally, I would like to display the subcategory and category in the normal way. Here's how to do it?
Below is the code of the request itself, if someone wants to understand it in more detail.
My task is to make an XLS price list according to information from the opencart database

SELECT oc_category_description.meta_description as category, oc_product_description.name as name, oc_product.quantity as quant, oc_product.price as price, oc_product.viewed as vived, oc_product.image as image
FROM `oc_product`,`oc_product_description`,`oc_product_to_category`,`oc_category_description`
WHERE 	oc_product.product_id=oc_product_description.product_id and oc_product.product_id=oc_product_to_category.product_id and oc_product_to_category.category_id=oc_category_description.category_id and oc_product.quantity>0
ORDER BY category, name
LIMIT 10

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question