I currently do the pagination. I already create the pagination for only one table and success. Now, I want to create the paging with join another table which mean I want to use LEFT JOIN. below is my current code
$query = $conn->prepare("SELECT * FROM ( SELECT *, ROW_NUMBER() OVER (ORDER BY Book_No)
as row FROM booking) a WHERE row between ".$offset." and ".$total_records_per_page."");
and I want to add Left Join same like this.
LEFT JOIN room ON booking.Room_ID = room.Room_ID WHERE Admin_email = '$Email'
can I know how to combine the query? Please help
Nothing much needs to change:
SELECT *
FROM
(
SELECT *, ROW_NUMBER() OVER (ORDER BY Book_No) AS row
FROM booking b
LEFT JOIN room r
ON b.Room_ID = r.Room_ID
WHERE Admin_email = :email
) a
WHERE row BETWEEN :start AND :end;
Sample script:
$sql = "SELECT * FROM (
SELECT *, ROW_NUMBER() OVER (ORDER BY Book_No) AS row
FROM booking b
LEFT JOIN room r
ON b.Room_ID = r.Room_ID
WHERE Admin_email = :email
) a
WHERE row BETWEEN :start AND :end";
$query = $conn->prepare($sql);
$query->execute([':email' => $email, 'start' => $offset,
'end' => $total_records_per_page]);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.