I wanted to select two columns from inner join of two select queries. I have written a query joining three tables and from the result I want to get only two column. But my query is showing error.I am using oracle sql developer.
SELECT firstname,surname
FROM (
SELECT A.firstname,A.surname,I.ACNUM,I.FIELDNUM
FROM ACADEMIC A INNER JOIN INTEREST I
ON (A.ACNUM = I.ACNUM)
INNER JOIN SUBJECT S ON (I.FIELDNUM = S.FIELDNUM) WHERE S.TITLE = 'History' ) ;
I want only the firstname and surname but I am getting error like:
Incorrect syntax near ';'.
Why are you using a subselect? Just use:
SELECT A.firstname, A.surname
FROM ACADEMIC A INNER JOIN
INTEREST I
ON A.ACNUM = I.ACNUM INNER JOIN
SUBJECT S
ON I.FIELDNUM = S.FIELDNUM
WHERE S.TITLE = 'History' ;
When you select from query you should name it as well. Try this:
SELECT D.firstname,D.surname
FROM (SELECT A.firstname,A.surname,I.ACNUM,I.FIELDNUM
FROM ACADEMIC A
INNER JOIN INTEREST I ON (A.ACNUM = I.ACNUM)
INNER JOIN SUBJECT S ON (I.FIELDNUM = S.FIELDNUM)
WHERE S.TITLE = 'History') D;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.