2 回答

TA贡献1876条经验 获得超5个赞
这是您可以使用的方法:
// Statement
$select = "select * from table where specific_row in ($strings_prepared)";
// Connect
$connect = mysqli_query($con, $select);
// Retrieve rows
$founded = [];
while ($row = mysqli_fetch_array($connect)) {
$founded[$row['specific_row']] = $row['column1']; // or whatever
}
foreach ($strings_prepared as $string) {
if (!empty($founded[$string])) {
echo 'found';
} else {
echo 'NOT found';
}
}

TA贡献1795条经验 获得超7个赞
您可以使用子查询创建包含要搜索的名称的派生表,并将其与表连接。
SELECT a.value, IF(b.specific_row IS NULL, 'not found', 'exists') AS found
FROM (
SELECT 'apple' AS value
UNION
SELECT 'orange'
UNION
SELECT 'pear'
UNION
SELECT 'banana'
) AS a
LEFT JOIN table AS b ON a.value = b.specific_row
- 2 回答
- 0 关注
- 337 浏览
添加回答
举报