gpt4 book ai didi

php - 从查询中按值查找特定字段

转载 作者:行者123 更新时间:2023-11-29 11:43:17 24 4
gpt4 key购买 nike

我有一个疑问:

SELECT * FROM custom_fields_values WHERE `custom_field_value_for_item-id` = 1

选择:

| custom_field_value_id | custom_field_for_item-id | custom_field_value | custom_field_to-compare_to |
|-----------------------|--------------------------|--------------------|----------------------------|
| 1 | 1 | test1 | 3 |
| 2 | 1 | test2 | 4 |

从我的 table 上。

如何访问 custom_field_value,其中 custom_field_to_compare_to == 3?我可以判断这是否不存在吗?

我知道我可以修改查询并立即选择它,但我需要缩小已执行查询的范围。

最佳答案

再次查询数据库可能更有意义。

但是,如果您想搜索已经检索到的结果,您可以使用例如 array_filter() .

一个简单的例子:

$search = "3";
$filtered_rows = array_filter($all_found_rows, function($value) use ($search) {
return $Value['custom_field_to-compare_to'] === $search;
}
);

关于php - 从查询中按值查找特定字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35397209/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com