如果我有一张像这样的 table
# | name |
----------
1 | 1 |
2 | 2 |
3 | 3 |
4 | 4 |
我如何检查表的 name 变量下的值是否为 4,以及它是否运行某些内容?
最佳答案
通过 php,您可以使用内置的 mysqli_num_rows() 函数,php documentation
mysqli_result::$num_rows -- mysqli_num_rows — Gets the number of rows in a result
$q = "select name from table where name = '4'";
$r = $mysqli->query($q);
if ($r->num_rows > 0) {
echo "exists";
} else {
echo "not exists";
}
关于php - 如何检查 MySQL 表中是否存在值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59572852/