CREATE TABLE IF NOT EXISTS `reservation_tables` ( `res_table_id` int(10) NOT NULL AUTO_INCREMENT, `res_table_name` int(10) NOT NULL, `date_time` varchar(20) NOT NULL, `partyhall_id` int(10) NOT NULL, `flag` enum('0','1') NOT NULL DEFAULT '0', PRIMARY KEY (`res_table_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ; INSERT INTO `reservation_tables` (`res_table_id`, `res_table_name`, `date_time`, `partyhall_id`, `flag`) VALUES (1, 1, '2014-08-17 12:00 am', 7, '1'), (2, 2, '2014-08-17 12:00 am', 7, '1'), (3, 3, '2014-08-18 12:00 am', 8, '1'), (4, 4, '2014-08-18 12:00 am', 8, '1'), (5, 1, '2014-08-25 12:00 am', 12, '1'), (6, 2, '2014-08-25 12:00 am', 12, '1'), (7, 3, '2014-08-20 12:00 am', 23, '1'), (8, 4, '2014-08-20 12:00 am', 23, '1');
ฮ you had to choose an accessible table name for matching date_time
Example select available table_name where date_time = 2014-08-18 12:00 am.
solution request: im sure this works well
SELECT distinct res_table_name FROM reservation_tables WHERE `res_table_name` NOT IN (SELECT `res_table_name` FROM reservation_tables where `date_time` = '2014-08-17 12:00 am')