您好,欢迎访问一九零五行业门户网

掌握PHP MySQL Where 子句

如何通过php mysql where 子句来操作数据库,本篇将详细的讲解其操作内容。
where 子句
where 子句用于提取满足指定标准的的记录。
语法
select column_name(s)from table_name
where column_name operator value
如需学习更多关于 sql 的知识,请访问我们的 sql 教程。
为了让 php 执行上面的语句,我们必须使用 mysqli_query() 函数。该函数用于向 mysql 连接发送查询或命令。
实例
下面的实例将从 persons 表中选取所有 firstname='peter' 的行:
<?php $con=mysqli_connect("localhost","username","password","database");// 检测连接if (mysqli_connect_errno()){ echo "连接失败: " . mysqli_connect_error();}$result = mysqli_query($con,"select * from persons where firstname='peter'");while($row = mysqli_fetch_array($result)){ echo $row['firstname'] . " " . $row['lastname']; echo "<br>";}?>
以上代码将输出:
peter griffin
本篇详解了where子句的相关知识,更多的学习资料清关注即可观看。
相关推荐:
怎样通过php mysql 读取数据
关于php mysql 预处理语句的相关知识
怎样通过php mysql 插入多条数据
以上就是掌握php mysql where 子句的详细内容。
其它类似信息

推荐信息