I want to create a hotel reservation system. For this system; the database is also used for another program ... But I have a problem: before booking, I want to see how many rooms are available for my order.
My table creates SQL queries
CREATE TABLE oteldb.oda ( oda_id INT (11) NOT NULL auto_increment, oda_tip_id INT (11) DEFAULT NULL, oda_adi VARCHAR (20) DEFAULT NULL, PRIMARY KEY (oda_id) ) ENGINE = MyISAM AUTO_INCREMENT = 1 CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE TABLE oteldb.tip ( tip_id INT (11) NOT NULL auto_increment, tip_adi VARCHAR (20) DEFAULT NULL, PRIMARY KEY (tip_id) ) ENGINE = MyISAM AUTO_INCREMENT = 1 CHARACTER SET utf8 COLLATE utf8_general_ci ROW_FORMAT = FIXED;
CREATE TABLE oteldb.rezervasyon ( rezervasyon_id INT (11) NOT NULL auto_increment, rezervasyon_gt DATE DEFAULT NULL, rezervasyon_ct DATE DEFAULT NULL, rezervasyon_oda_id INT (11) DEFAULT NULL, PRIMARY KEY (rezervasyon_id) ) ENGINE = MyISAM AUTO_INCREMENT = 1 CHARACTER SET utf8 COLLATE utf8_general_ci;
I try this but not work
SELECT * FROM oteldb.tip WHERE IN tip.tip_id (SELECT oteldb.oda.oda_tip_id FROM oteldb.oda WHERE IN oda.oda_id note (SELECT oteldb.rezervasyon.rezervasyon_oda_id FROM oteldb.rezervasyon WHERE "2012-01-03" BETWEEN AND rezervasyon_ct rezervasyon_gt AND "2012-01-22" AND BETWEEN rezervasyon_gt rezervasyon_ct))
thanks now ...
source share