Reputation: 353
I have two database tables 1). Table structure 2). Booking table
I want to get availability of booking table for current date and time.
Table structure
Booking Table
When i request table availability for date 2014-11-05 and booking time at 11:00:00 it should compare booking table with table structure and display only available tables. I need Mysql Query to perform this operation..
Upvotes: 0
Views: 2212
Reputation: 968
SELECT
`bookingtable.restaurant_table`,
`bookingtable.no_people`,
`bookingtable.booking_date`,
`bookingtable.bookingend_time`,
`bookingtable.bookingstart_time`
FROM `bookingtable`
LEFT OUTER JOIN
`bookingtable` ON `bookingtable.restaurant_table` = `tablestructure.table_no`
WHERE
`bookingtable.booking_date` = "2014-11-05"
AND
`bookingtable.booking_time` = "11:00:00"
This is what I would do, however I would store the dates and times as UNIX timestamps personally
Upvotes: 3