2 回答
TA贡献2016条经验 获得超9个赞
首先,以数组形式获取数据
$db = \Config\Database::connect();
$query = $db->query("select * from g WHERE g_status = '0' ORDER BY g_date ASC Limit 10;");
$g_results = $query->getResult('array');
$g_amounts = array_column($g_results,'g_amount');
$query2 = $db->query("select * from g WHERE p_status = '0' ORDER BY p_date ASC Limit 10;");
$p_results = $query2->getResult('array');
$p_amounts = array_column($p_results,'p_amount');
foreach(array_intersect($g_amounts,$p_amounts) as $amount){
echo "do something";
}
TA贡献1808条经验 获得超4个赞
为什么不使用 aJOIN
看看它是否返回一些东西?不确定我的语法是否正确,我不经常进行 JOIN:
SELECT * FROM g g_table JOIN p p_table ON g_table.g_amount = p_table.p_amount WHERE g_table.status = '0' AND p_table.status = '0'
- 2 回答
- 0 关注
- 128 浏览
添加回答
举报