J
J
Jazz75RUS2016-07-24 15:11:38
MySQL
Jazz75RUS, 2016-07-24 15:11:38

How to implement a selection by a parameter of the "multiple choice" type?

Good everyone, there is a "param" parameter with the "multiple choice" type, you need to filter for example:
Document1 (param=white, blue, red)
Document2 (param=white,)
Document3 (param=blue, red)
Document4 (param=black )
It is necessary to display similar documents with a match of one of the values, for example, Document2 and Document3 correspond to Document1, and Document1 only to Document3, nothing is displayed to Document4, etc.
I hope I explained it clearly :)
There was a tag saver on evo, there seems to be nothing like it on rev, there is an article through requests https://modxclub.ru/topics/mnozhestvennaya-vyibork...
но хочется чего нибудь попроще, ведь наверняка это частый вопрос и должны быть готовые решения, кстати выборка по похожим документам сейчас производится через такую конструкцию:

Answer the question

In order to leave comments, you need to log in

2 answer(s)
U
utyfua, 2016-07-24
@utyfua

FIND_IN_SET(str,strlist)
Returns a value from 1 to N if the string str is present in the list strlist of N substrings. The list of strings is a string consisting of substrings separated by `,' characters. If the first argument is a constant string and the second argument is a SET column, the FIND_IN_SET() function is optimized to use binary arithmetic! Returns 0 if str is not in strlist or if strlist is the empty string. If one of the arguments is NULL, 0 is returned. This function will not work correctly if the first argument contains a `,' character:
mysql> SELECT FIND_IN_SET('b','a,b,c,d');
-> 2

J
Jazz75RUS, 2016-07-28
@Jazz75RUS

https://modxclub.ru/topics/mnozhestvennaya-vyibork...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question