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
Exchange 2010 replication over a WAN with high latency
Predicted harddrive failure
jquery validator and asp.net updatepanel
Move Sharepoint 2010 DB's from one server to another
disk IOP calculation
usercontrols, docking and scrolling problems
Changing C++ unmanaged DateTime to C# DateTime MYSQL db
Suitable Backup Solution requested
Boot Acer Ferrari 1200 laptop from dvd to upgrade vista to windows 7
Ajax or flash..For online Jewellery designer ?