I
I
Ibishka2020-07-08 13:04:30
PHP
Ibishka, 2020-07-08 13:04:30

How to find a product by Mysql colors?

I have goods in the db and it has a colors field in which I write like this black,yellow,green, etc. and I have an array of colors selected by a person, how to take those products that have all the colors from the array in the field?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
F
FanatPHP, 2020-07-08
@FanatPHP

There should not be a field "which I write like this black,yellow,green ".
There must be a separate table , in which the record id and color,
then the search is done by a simple join.

A
Alexander Bondarenko, 2020-07-08
@bond_1013

Use SQL queries, you can search by several criteria at once

SELECT * FROM [Шарики] WHERE [Цвет] IN ('Красный','Зеленый','Белый','Синий')

https://code-live.ru/post/custom-search-for-site-w...

X
xmoonlight, 2020-07-08
@xmoonlight

Binary "mask" becomes an id-shnik for the aggregate set.
1+2+4+8+16+32+........

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question