我有 2 张桌子,Facilities
并且Services
.
CREATE TABLE Facilities (
facility_id NUMBER(2) NOT NULL,
facility_name VARCHAR2(20) NOT NULL,
CONSTRAINT pk_facil_id PRIMARY KEY (facility_id)
);
CREATE TABLE Services (
service_id NUMBER(2) NOT NULL,
service_name VARCHAR(20) NOT NULL,
service_facility NUMBER(2) NOT NULL,
CONSTRAINT pk_serviceid PRIMARY KEY (service_id)
);
ALTER TABLE Services
add CONSTRAINT fk_servicefacility FOREIGN KEY(service_facility)
REFERENCES Facilities(facility_id);
如果我尝试将记录输入到“服务”表中,如下所示:
INSERT INTO Services (service_id, service_name, service_facility)
SELECT 06, 'Rooms',
(SELECT facility_id, FROM Facilities WHERE facility_name = 'Hotel')
FROM Dual;
7 个插入语句中有 3 个出现错误“缺少表达式”。缺少什么表情?