SQL,检查表中所有记录的值是否大于5


SQL, Checking if all record's value greater than 5 in a table

我正在使用PHP,我需要一个sql查询,将检查是否所有记录值大于5..不会从数据库返回任何数据。如果所有记录大于5,则返回true。

如果答案为真,我将更新另一个表。

伪码是

if(the value column in table1 is greater then 5 for all records)
then
    $update = mysql_query("UPDATE table2 SET q_value = '0' ")
else
do nothing

Table Example:
------------------------
| question |  value   |
|    X1    |     6    |
|    X2    |     6    |
|    X3    |     6    | //value column for all records are greater then 5 
|    X4    |     7    | //must return true
|    X5    |     8    | //and will update table2
|    X6    |     6    |
| question |  value   |
|    X1    |     6    |
|    X2    |     3    |
|    X3    |     0    | //value column for all records not greater then 5 
|    X4    |     7    | //there are 0 and 3 values and must return false
|    X5    |     8    | //won't update table2 
|    X6    |     6    |

你能给我一个想法吗?我怎么能查到所有的记录呢?不会返回任何数据。

提前感谢

select count(*)
from table1
where value <= 5

如果返回0,则为TRUE,否则为FALSE。