[英]Get specific row from dataset using fetch_assoc?
If I am using the below query and lets say that it returns the below dataset 如果我使用下面的查询,可以说它返回下面的数据集
SELECT p.`id`,
s.`name`,
d.`deployStatus`,
d.`deployedDate`
FROM `patches` AS p
LEFT JOIN `deployed` AS d ON d.`PatchID` = p.`id`
LEFT JOIN `servers` AS s ON s.`id` = d.`serverID`
WHERE p.`id` = 2
| id | name | deployStatus | deployedDate |
|____|______|______________|______________|
| 2 | test | 1 | 06/14/2013 |
| 2 | prod | null | 06/14/2013 |
Is there a way with the while($row = $results->fetch_assoc()){
command that I can return only the "test" row, without having the change the sql query? while($row = $results->fetch_assoc()){
命令有没有办法让我只返回“ test”行,而无需更改sql查询?
Use if condition and check whether it is your desired row or not. 使用if条件并检查它是否是您想要的行。
while($row = $results->fetch_assoc()){
if($row['name'] == "test") {
// echo here your result
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.