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
Sage ACT 2010 - How to create the database in the server and provide connection for remote computers
Some sort of offline form that will save entries of data from several users
What does src="#" mean when used in a bgsound attribute and is it needed?
Run the first php script in background - When done - run the next script ...
threads in mfc
Help to decipher/reset BIOS settings on a Gigabyte MB!!!
Best way to find out what a user has access to on a file server
IPSEC access into ASA via second Internet connection
Clear only first 5 columns
Airport Code with reverse geo coding with google maps api