Answer the question
In order to leave comments, you need to log in
How to generate such sql query?
Good afternoon!
SELECT * FROM oc_product WHERE product_id IN (
SELECT * FROM oc_product_to_category WHERE category_id IN (
SELECT category_id FROM oc_product_to_category WHERE product_id = '1'
)
) limit 6
Answer the question
In order to leave comments, you need to log in
So write.
Only in subqueries it is not necessary to pull out all the fields, but only the id:
SELECT * FROM oc_product
WHERE product_id IN (
SELECT product_id FROM oc_product_to_category
WHERE category_id IN (
SELECT category_id FROM oc_product_to_category
WHERE product_id = '1'
)
)
LIMIT 6
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question