0
SELECT s_fname
FROM (SELECT s_fname from student) as s_n
WHERE s_n like 'Youss%';

i get this error with multiple subqueries and cant get it right. ORA-00933: SQL command not properly ended

Frag Rich
  • 3
  • 1
  • `WHERE s_n` should be `WHERE s_n.s_fname` I think – Joe Phillips May 24 '22 at 21:13
  • In Oracle, the `AS` keyword before a table alias is forbidden and is a syntax error. Remove the `AS` keyword and the "command not properly ended" error will be replaced with the next error (you also want `WHERE s_fname LIKE 'Youss%'`). – MT0 May 24 '22 at 21:55

2 Answers2

-1

Like this:

SELECT s_fname
FROM (SELECT s_fname from student) s_n
WHERE s_fname like 'Youss%';

Or try it this way:

with (select s_fname from student) as s_n
select s_fname from s_n
where s_fname like 'Youss%';

That said, other than as an exercise, there's no practical reason to use a subquery here. Better just to say this:

select s_fname 
from student 
where s_fname like 'Youss%';
pmdba
  • 6,457
  • 2
  • 6
  • 16
-1
SELECT s_fname
FROM (SELECT s_fname from student) as s_n
WHERE s_n.s_fname like 'Youss%';

You're using a WHERE clause on a table, not a field

Also you could just write this instead in your particular case:

SELECT s_n.s_fname
FROM student as s_n
WHERE s_n.s_fname like 'Youss%';
Joe Phillips
  • 49,743
  • 32
  • 103
  • 159