Jump to content

help me in this simple query , please !


quecoder

Recommended Posts

HI , I have a bookings table for  hotel rooms reservations , a customer makes a reservation , for example , 2 double rooms and 1 family room .. for each room type ( double , family ) I insert one record in bookings that has the room id for this type and quantity ..so , if double room has an ID = 1 , and family ID = 2 , I place the following :

 

booking_id  cust_id  room_id    quantity  checkin          checkout    booking_time  Pay_due_amount

1                  123      1              2      1205532000    1205618400    1205532000          600

 

booking_id  cust_id  room_id    quantity  checkin          checkout    booking_time  Pay_due_amount

2                  123      2              1      1205532000    1205618400    1205532000          600

 

 

pay_due_amount is the total payment for both rooms . so every thing is fixed except room_id , quantity

.

dates are of data type INT , I store the time stamp in them.

 

Question is :

when I query for his last five orders in his member area  , ((( he may place another order after half an hour and the booking time will be changed for all records for this order ))) , how to distinguish between records and group the ones with same order together , like , to get all data with similar booking_time  for that customer ( cust_id) ... is this right ?? and if yes , how to make it?

 

Link to comment
https://forums.phpfreaks.com/topic/96386-help-me-in-this-simple-query-please/
Share on other sites

another demonstration:

 

 

booking_id  cust_id  room_id    quantity  checkin          checkout    booking_time  Pay_due_amount

1                  123      1              2      1205532000    1205618400    1205532000          600

 

booking_id  cust_id  room_id    quantity  checkin          checkout    booking_time  Pay_due_amount

2                  123      2              1      1205532000    1205618400    1205532000          600

 

 

And ORDER AFTER some time from the same customer :

 

 

 

booking_id  cust_id  room_id    quantity  checkin          checkout    booking_time  Pay_due_amount

1                  123      2              4      1205532000    1205964000  1205665517          600

 

booking_id  cust_id  room_id    quantity  checkin          checkout    booking_time  Pay_due_amount

2                  123      3              2      1205532000    1205964000    1205665517          600

 

 

Changes are : room_id , Quantity for every record , but the same  booking_time for every record of them ... this may consider unique for each customer because this timestamp is with seconds ...checkin  and checkout may not be unique for sure .

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.