B
B
badEd2018-03-27 02:27:35
MySQL
badEd, 2018-03-27 02:27:35

How to correctly query multiple tables?

Good evening.
The site is an online store.
My task is to select from the table where product ids and category ids are stored, only those product ids that have category 175. Also, pull out all the data on them (headers, meta tags, and much more that is stored in other tables).
To do this, I concocted such a request. But the trouble is that after such a request, the server is reloaded and all sites on it "give 504". Asked similar request on Denver. The same situation - does not return anything, but all sites that are on Denver stop opening.
PS There are about 20 thousand items of goods on the site.
What could be the problem?
SELECT a.products_id, a.categories_id, b.products_name, b.products_id, b.products_description, b.products_short_description, b.products_keywords, b.products_meta_title, b.products_meta_description, b.products_meta_keywords, c.products_image, c.products_price, c .products_price2, c.products_ordered, d.options_values_price, e.products_attributes_filename, e.products_attributes_password, e.products_attributes_maxdays
FROM products_to_categories a
INNER JOIN products_description b
INNER JOIN products c
INNER JOIN products_attributes d
INNER JOIN products_attributes_products_id e
ON b.products_download
e a.categories_id = 175

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Tolerant, 2018-03-27
@mres

Try to add an exclusion of products, for example those with the "Do not show" status.
Use limit .

R
Rsa97, 2018-03-27
@Rsa97

Are you sure you need the full Cartesian product of all tables? First, add a join condition to each JOIN.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question