G
G
godyesnow2017-04-04 16:56:31
Python
godyesnow, 2017-04-04 16:56:31

How to select products from a table by dynamic parameters (located in another table)?

Hello, the situation is this: there is a table of products (products of different categories, such as computers and chairs, cartridges, etc.) and there is a table of product properties (by type product - property - value) and I can’t create a request for a selection by several parameters, since with joine 'e of these tables, several rows of one product are obtained in each one separate property. Maybe someone knows how to select products by several parameters, if for example I need a product with color = black and interface = usb? Thank you in advance for your help.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
longclaps, 2018-03-07
@longclaps

print(re.sub(r'aa+', lambda t: '(' + ('a+' * len(t[0]))[:-1] + ')', s))

R
Rsa97, 2017-04-04
@Rsa97

Multiple JOINs, each filtering only one parameter.

D
d-stream, 2017-04-04
@d-stream

General idea:

left join таблица_свойств
...
where id_в_таблице_свойств is not null

In especially wide-ranging cases, we group all this select by id or distinct according to taste and use it as an inner join to the product table

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question