Arockiaraj
Arockiaraj

Reputation: 353

Mysql Query to get booking availability for reservation system

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

Table structure

Booking Table

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

Answers (1)

JustSteveKing
JustSteveKing

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

Related Questions