Microsoft
Software
Hardware
Network
Question : Insert Statement using values and select subquery
Hi..
I'm trying to do Insert statement using values and select query,
I have 5 tables:
- INVOICE Table: that has INVNO column as primary key,
- COMPANIES Table : that has CNO column as primary key,
- STUDENTS Table: that has SNO column as primary key and CNO Column as foreign key,
- INVOICED Table: that has INVNO, SNO and both of them are foreign key ,
- STUDCRS Table : that has SNO column as a foreign key
now I want to insert data into INVOICED Table using the following Statement:
INSERT INTO INVOICED(INVNO,SNO)VALUES(
1,(SELECT STUDCRS.SNO FROM STUDCRS
INNER JOIN STUDENTS ON STUDENTS.SNO = STUDCRS.SNO
INNER JOIN COMPANIES ON COMPANIES.CNO = STUDENTS.CNO
WHERE STUDCRS.CRSNO=1 AND STUDENTS.CNO=1))
but I'm facing this error:
ORA-01427: single-row subquery returns more than one row
this statement working if I try to insert one row, but its not working with multiple rows
how can I fix that
Answer : Insert Statement using values and select subquery
INSERT INTO INVOICED(INVNO,SNO)
SELECT 1, STUDCRS.SNO
FROM STUDCRS
INNER JOIN STUDENTS ON STUDENTS.SNO = STUDCRS.SNO
INNER JOIN COMPANIES ON COMPANIES.CNO = STUDENTS.CNO
WHERE STUDCRS.CRSNO=1
AND STUDENTS.CNO=1
Random Solutions
Sql Subquires
CVV2 checker for C# code
Citrix Receiver for Blackberry devices
screenprint32 does not work on windows 7 what is a replacement ?
SOAP, WEB Service, VB.NET
Connect to customer's pc using free utils
ForeFront - TMG
WDS Server 2008 R2 - PXE Error
MAC Os 10.4 Startup problem.
how to transfer apps from my iphone to my itunes library