I'm currently working on my query. So I have two tables, tbl_room and tbl_reservation. I wanted to do an update query with the following conditions:
Decrement room counter by 1 in tbl_room if:
- The first and last name of the customer matches the first and last name in the tbl_reservation
- The tbl_reservation room ID matches with the tbl_room room ID
I'm currently stuck with this:
$result = mysql_query("UPDATE
tbl_room
JOIN tbl_reservation
ON tbl_room.roomID = tbl_reservation.roomID
AND tbl_reservation.cus_fname = '$cusFN'
AND tbl_reservation.cus_lname = '$cusLN' SET tbl_room.reserve = reserve - 1 ");
These are my tables:
----------
tbl_room
----------
roomID,
room_type,
capacity,
reserve <--- reservation counter
----------
tbl_reservation
----------
reserveID,
cus_fname,
cus_lname,