R
R
Roman2020-02-18 17:59:07
MySQL
Roman, 2020-02-18 17:59:07

How to get multiple records from a Mysql table?

Good afternoon!

There is a form with a numeric field, which determines the price of services.
There is a database with a range of values ​​for these fields - 32, 102, 152, etc.
The user enters, for example, 45
How to select rows with values ​​32 and 102 from mysql? Option

select * from table_name where param > 45 and param < 45
does not give the desired result (it is understandable).

What can be done in this situation?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
K
Konstantin Tsvetkov, 2020-02-18
@Ramapriya

SELECT MAX(start_diameter) FROM table_name WHERE (start_diameter <= 145)
UNION ALL
SELECT MIN(start_diameter) FROM table_name WHERE (start_diameter >= 145)

P
Pringell, 2020-02-18
@Pringell

"SELECT * FROM `table_name` WHERE param='32' OR param='102'" - Lists all rows with param where they are either 32 or 102

R
Roman, 2020-02-18
@Ramapriya

I found the solution myself :)

SELECT * FROM `DIAMETERS` WHERE start_diameter <= 102 ORDER BY start_diameter DESC LIMIT 1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question