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
Maintain cloumn width while using datasheet view
Certificate Authority 2003, 2008 Enterprise Root CA
Delphi 'LIKE' DateTime filter
Oracle Form 4.5 Update Allowed Problem
Blackberry device stopped synching after mailbox move
get last 4 digit
jQuery dialog positioning problem
I need to change the color of a DataGridView scrollbar in C# WinForms
TempDB N # of CPU's
check_directory_files