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
HTTP Error 404.3 on IIS 7.0
How can I convert a custom control that calls User32 and Shell32 to work on Mono?
How do I change the style.css with Javascript?
Inserting another drawing
Cron Error with 1 and 1 dedicated server - linux
How to read a CSV using Windows Command Line
Sharepoint Webpart page load event issue
Windows 7 Sounds Controls (device at Volume 0 but can still hear)
Intel Sata RAID controller on RHEL 4 problem
OCS Edge Server R2 2007