I'm trying to make a query based on the result of another query, the principal query is this:
SELECT d.nombre, d.apellido,em.codigo, em.descripcion, d.iddocente, em.idequipoMulti
FROM docenteequipomulti dem
INNER JOIN docente d ON dem.docente_iddocente=d.iddocente
INNER JOIN equipomulti em ON dem.equipoMulti_idequipoMulti=em.idequipoMulti
WHERE
dem.iddocenteEquipoMulti LIKE '%(subquery)%'
without the where
it show me all the values, but I have to filter them by the value returned by the subquery.
This is the subquery:
SELECT concat_ws ('-', m.numModulo, p.periodo) AS MPeriodo FROM modulos m INNER JOIN periodo p ON m.periodo_idperiodo=p.idperiodo WHERE m.estado=1
That query always will get one value for example "1-2015", but I put the subquery into the "()" and didn't work. What am I doing wrong?
Edit: I have some ids like this
1--1-2015--Eq1
1--1-2015--Eq2
2--1-2015--Eq3
1--2-2015--Eq1
The idea is to filter those ids that have "1-2015" no matter what else they have, so it has to show only the 3 rows, excluding the last one.
Well, I couldn't make work as I want it, instead I made the subquery, Save it into a variable and then use it as a parameter for the principal query, thanks for the help.