2 回答

TA貢獻(xiàn)2016條經(jīng)驗(yàn) 獲得超9個(gè)贊
首先,以數(shù)組形式獲取數(shù)據(jù)
$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貢獻(xiàn)1808條經(jīng)驗(yàn) 獲得超4個(gè)贊
為什么不使用 aJOIN
看看它是否返回一些東西?不確定我的語(yǔ)法是否正確,我不經(jīng)常進(jìn)行 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 關(guān)注
- 169 瀏覽
添加回答
舉報(bào)