*父表* : 车辆
CREATE TABLE `vehicle` (
`vehicle_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`version_number` INT(10) UNSIGNED NULL DEFAULT '0',
`vehicle_no` VARCHAR(64) NOT NULL COLLATE 'utf8_bin',
`vehicle_reg_no` VARCHAR(64) NOT NULL COLLATE 'utf8_bin',
`vehicle_name` VARCHAR(64) NOT NULL COLLATE 'utf8_bin',
`total_seat` INT(15) NOT NULL,
`route_id` INT(10) UNSIGNED NOT NULL,
`available_seat` INT(10) UNSIGNED NOT NULL,
PRIMARY KEY (`vehicle_id`)
)
子表: allocate_vehicle
CREATE TABLE `allocate_driver` (
`allocate_driver_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`version_number` INT(10) UNSIGNED NULL DEFAULT '0',
`vehicle_id` INT(10) UNSIGNED NOT NULL,
PRIMARY KEY (`allocate_driver_id`),
INDEX `fk_vehicle_idx` (`vehicle_id`),
CONSTRAINT `fk_vehicle_idx` FOREIGN KEY (`vehicle_id`) REFERENCES `vehicle` (`vehicle_id`) ON UPDATE NO ACTION ON DELETE NO ACTION,
)
所以我给出了这个查询:select veh.* from vehicle as veh JOIN allocate_driver as allDr on veh.vehicle_id!=allDr.vehicle_id
但不能正常工作......在插入之前,我想要在分配每辆车后它不应该显示在列表中的车辆列表..任何人都可以告诉我..提前谢谢:)