Hi all, I know how to do this query with subqueries like this:
select * from traf_oper where rutasalien in (select ruta_salid from rutas where codigo_ope = 0) and rutaentran in (select ruta_salid from rutas where codigo_ope > 0)
--------------------------------------------------------------
I tried to do this:
mysql> explain select a.* from traf_oper a join rutas b on a.rutasalien = b.ruta_salid where b.codigo_ope = 0 and
a.rutaentran = b.ruta_salid where b.codigo_ope > 0;
ERROR 1064: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version
for the right syntax to use near 'where b.codigo_ope > 0' at line 1
How can I substitute multiple subqueries with JOIN's? Thanks in advance.
Hi guys, just to let you know how I solved it!
select a.* from traf_oper a join rutas r1 on a.rutasalien = r1.ruta_salid and r1.codigo_ope = 0 join rutas r2 on a.rutaentran = r2.ruta_salid and r2.codigo_ope > 0
Nice, isn't it? :) Hector
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]