Michael Beaucourt wrote:
> 
> Hi all,
> 
> I was wondering if it is possible to perform an inner select in MySQL.
> I have a database called EMP and when i enter the following query, I
> keep getting error 1064:
> 
> select ename,deptno from emp where deptno in (select deptno from emp
> where ename = 'SCOTT')
> 
> The error message reads as follows:
> ERROR 1064: You have an error in your SQL syntax near 'select deptno
> from emp where ename='scott')' at line 1
You can achieve it by writing this query in the following way:
select a.ename,a.deptno from emp a,emp b where a.deptno=b.deptno and
b.ename='SCOTT'; 
MySQL doesn't support subselects;
-- 
_/        _/  _/_/_/  -----     Rafał Jank [EMAIL PROTECTED]     -----
 _/  _/  _/  _/   _/         Wirtualna Polska SA   http://www.wp.pl 
  _/_/_/_/  _/_/_/    ul. Uphagena 2, 80-237 Gdansk, tel/fax. (58) 5215625
   _/  _/  _/         --------==*  http://szukaj.wp.pl *==----------

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to