创建一个SQL语句,通过比较一行中的两个字段来查询MySQL数据库

I have a table as example below:

Prices

ID*low*high**value

1*1*4**29.0

2*5*9**32.0

3*10*25**50.0

low and high are both INT

I've tried: $SQL = "SELECT value from Prices WHERE low >= '2' AND high <= '2' but I come up with zero (0) results returned where in this example I'm wanting to find 29.0

edited my table above as it was unclear after I saw it formated.

I cannot see a high <= 2 in your example above. You might wanna review that.

$SQL = "SELECT value from Prices WHERE low >= '2' AND high <= '2'"

The above code you showed us is correct.

I believe you want it switched around to find value 29.0:

$SQL = "SELECT value from Prices WHERE low <= '2' AND high >= '2'"

@Rick beat me to the logical error in your query. Just gonna add you should use backtics around field and table names (at least for value here as I think that might be a future reserved keyword). Also, if low and high are int type, you shouldn't surround values for them in quotes. Though mysql might convert them accordingly, you are specifying strings.

SELECT `value` from `Prices` WHERE `low` <= 2 AND `high` >= 2