There is a minimum value and a maximum value, and the database is also designed into two fields, the maximum and the minimum. How does sql search according to the user input range?

frontend input: length: 100,200
background:
minimum database length minLen, maximum length maxLen
how to search sql

Mar.22,2021

this input if there is no'-', how can you do


//'-'php
$str = '100 - 200';
$arr = explode('-',$str);
if($arr[0] > $arr[1])
{
    $min = (int)$arr[1];
    $max = (int)$arr[0];
}else{
    $min = (int)$arr[0];
    $max = (int)$arr[1];
}
//sql
select * from sql where minLen >= $min and maxLen <= $max;

first of all, you do not say which language is used in the background, so you do not say the writing of the language, but as a direct database operation. Mysql database has related character interception and character splitting functions, you can use the corresponding functions to intercept and split, and then use it. However, I suggest that it is more appropriate to generate a reasonable sql statement and then query it through the back-end processing.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1c11cbc-32d9c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1c11cbc-32d9c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?