作者:郑子宜4262 | 来源:互联网 | 2023-05-17 20:59
I have two tables:
我有两张桌子:
- bookingbook
- bookingbook
- borrowbook
- borrowbook
and I need to search the column bookId
in each table if it's exist or not
如果它存在与否,我需要在每个表中搜索列bookId
My code
我的代码
prepare('SELECT
a.bookId, b.bookId
FROM
bookingbook AS a
INNER JOIN borrowbook AS b ON (a.bookId = b.bookId)
WHERE a.bookId=? OR b.bookId=?
');
$checkBorrow->bind_param('ii', $bokId, $bokId);
$checkBorrow->execute();
$res = $checkBorrow->get_result();
$numRows = mysqli_num_rows($res);
if ($numRows > 0) {
$states = "Not Available";
} elseif ($numRows <= 0) {
$states = "Available";
}
}
?>
Result always comes Available
even if it's not
结果总是可用即使不是
bookingbook Table
id - insId - bookId - studentId
bookingbook Table
id - insId - bookId - studentId - borrowDate - restoreDate
1 个解决方案