Answer the question
In order to leave comments, you need to log in
How to create a condition on multiple columns?
There is a similar structure:
title | price1 | price2 | price3
---------------------------------
t1
24 32 55
t2 25 85 38
The condition included the price condition (from 30 to 60, for example) and the selection was similar:
title: t1, price2: 32
title: t1, price3: 55
title: t2, price3: 38
That is, that only one cost participated in the selection. If more than one value satisfies a line, you need it to be split into several lines as a result (as shown from the t1 examples)
Answer the question
In order to leave comments, you need to log in
This suggests creating several queries and combining them through UNION
SELECT CONCAT('title: ', title, ', price1: ', price1)
FROM my_table
WHERE price1 BETWEEN 30 AND 60
UNION
SELECT CONCAT('title: ', title, ', price2: ', price2)
FROM my_table
WHERE price2 BETWEEN 30 AND 60
UNION
SELECT CONCAT('title: ', title, ', price3: ', price3)
FROM my_table
WHERE price3 BETWEEN 30 AND 60
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question