0

这是三个表的sql

CREATE TABLE `reservation` (
  `cust_id` int(50) NOT NULL,
  `reservation_id` int(25) NOT NULL,
  `car_id` int(50) NOT NULL,
  `total` varchar(50) NOT NULL,
  `pulocation` varchar(50) NOT NULL,
  `dolocation` varchar(50) NOT NULL,
  `pudate` varchar(50) NOT NULL,
  `dodate` varchar(50) NOT NULL,
  `putime` varchar(25) NOT NULL,
  `dotime` varchar(25) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


CREATE TABLE `car` (
  `car_id` int(25) NOT NULL auto_increment,
  `car_name` varchar(50) NOT NULL,
  `rental` varchar(50) NOT NULL,
  `category` varchar(50) NOT NULL,
  `category_id` varchar(10) NOT NULL,
  `details` text NOT NULL,
  `date_added` date NOT NULL,
  `Status` varchar(50) NOT NULL,
  PRIMARY KEY  (`car_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=34 ;



CREATE TABLE `customer` (
  `cust_id` int(11) NOT NULL auto_increment,
  `fname` varchar(50) NOT NULL,
  `lname` varchar(50) NOT NULL,
  `address` varchar(100) NOT NULL,
  `city` varchar(50) NOT NULL,
  `country` varchar(50) NOT NULL,
  `zip` varchar(50) NOT NULL,
  `DOB` varchar(50) NOT NULL,
  `email` varchar(50) NOT NULL,
  `username` varchar(50) NOT NULL,
  `password` varchar(50) NOT NULL,
  PRIMARY KEY  (`cust_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;

cust_id 和 car_id 是汽车和客户表的外键。所以我必须编写一个查询来检查预订表中的 pudate 和 dodate 之间的汽车是否可用。任何帮助将不胜感激

4

0 回答 0