Php SQL,检查表中所有记录的值是否大于5
我正在使用PHP,我需要一个sql查询,它将检查所有记录的值是否大于5。。不会从数据库返回任何数据。如果所有记录都大于5,Just将返回true 如果答案为真,我将更新另一个表 伪代码是Php SQL,检查表中所有记录的值是否大于5,php,mysql,sql-server,Php,Mysql,Sql Server,我正在使用PHP,我需要一个sql查询,它将检查所有记录的值是否大于5。。不会从数据库返回任何数据。如果所有记录都大于5,Just将返回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
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 |
你能给我一个主意吗。如何检查所有记录的内容。不会返回任何数据。如果所有值都大于某个值,则返回true
先谢谢你
select count(*)
from table1
where value <= 5
如果返回0,则为TRUE,否则为FALSE。您能显示您的实际代码吗?大于is>-大于或等于is>=无法添加答案,但看起来很像您正在查找的“如果不存在”,请从表1中选择1,其中的值我到目前为止没有听说过“如果不存在”命令。但我试过了,用这个查询就行了。非常感谢。非常感谢。这对我很有帮助。。