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
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 .

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.