OK, first let me say this is complicated. I know that a presentation can be a little long. But I, as you are with me, and help me in any case: D
So, I am developing an advanced bike search. I have many tables that I need to join to find all, say, red and brown bicycles. One bike can have more than one color! I made this request now:
SELECT DISTINCT p.products_id,
products_name,
products_attributes_id,
pov.products_options_values_name
FROM products p
LEFT JOIN products_description pd
ON p.products_id = pd.products_id
INNER JOIN products_attributes pa
ON pa.products_id = p.products_id
LEFT JOIN products_options_values pov
ON pov.products_options_values_id = pa.options_values_id
LEFT JOIN products_options_search pos
ON pov.products_options_values_id = pos.products_options_values_id
WHERE pos.products_options_search_id = 4
OR pos.products_options_search_id = 5
My first concern is a lot of associations. The table Productsbasically contains the product identifier, and the image and table Products Descriptioncontain more descriptive information such as the name (and product identifier, of course).
Products Options Values, . Products Options Search (products_options_search_id). 4 ( - 5).
"--", Products Attributes.
, : ? ?
: , , SELECT DISTINCT. , - INNER JOIN. , PHP-?
-: (.. ). , . , , , - . (. ). OR WHERE, , - . ?
, . : D