Home > database >  Enter a numeric value, return in accordance with the scope of numerical data
Enter a numeric value, return in accordance with the scope of numerical data

Time:09-26

Title may not explain
The date of temperature
10.20 10-20
10.21 10-15

I type 17 can return to the following content of this article
The date of temperature
10.20 10-20

Could you tell me how to write thank you want to achieve this effect SQL statements

CodePudding user response:

Suggested that the temperature of the column apart into two maximum temperature and minimum temperature field, so you need to determine x> The lowest temperature and xIf you just want to according to a field, it had to write their own a split function, apart into two Numbers to determine again

CodePudding user response:

A little research, found there is a solution
 
SELECT * FROM T
WHERE CAST (SUBSTRING_INDEX (` ` temperature, '-', 1) AS SIGNED INTEGER) & lt; 17
AND CAST (SUBSTRING_INDEX (` ` temperature, '-', 1) AS SIGNED INTEGER) & gt; 17


CodePudding user response:

SELECT
*
The FROM
T
WHERE 17 BETWEEN CAST (
SUBSTRING_INDEX (' temperature ', '-', 1) AS SIGNED INTEGER
)
AND CAST (
SUBSTRING_INDEX (' temperature ', '-', 1) AS SIGNED INTEGER
);

  • Related