skip to Main Content

I don’t understand how to fix this. PhpMyAdmin cannot find columns. I even gave each query a name but it doesn’t work.

SELECT ename, 
       deptno FROM ( SELECT sal 
                     FROM emp T
                   ) as E 
WHERE deptno = 10;

3

Answers


  1. you have not a column named ename in the subquery that you are use as table

    could be you don’t need the subquery

    SELECT ename, deptno 
    FROM emp WHERE deptno = 10;
    

    or if you really need the subquery then this must contain the column you are looking for

    SELECT ename, deptno 
    FROM (SELECT ename, deptno, sal FROM emp T) as E WHERE T.deptno = 10;
    
    Login or Signup to reply.
  2. Your sql is wrong, you are trying to select ename and deptno columns from table E. E alias from (SELECT sal FROM emp T), so it has the only one field named sal.

    Login or Signup to reply.
  3. SELECT sal FROM emp T, return a table with only "sal" column. You select column ename and deptno from a table have only sal column is impossible.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search