SQL - SELECT ??

 
Vista:

SELECT ??

Publicado por beto (2 intervenciones) el 14/06/2007 00:52:22
TENGO UNA TABLA 'CATEGORIASINMUEBLES' QUE SURGE DE UNA RELACION.
CAMPOS:
ID (PRIMARIA)
inmuebleID (FORANEA)
categoriaID (FORANEA)

LAS CATEGORIAS SON POR EJEMPLO: TERRAZA , PISCINA ETC

QUIERO OBTENER EL INMUEBLEID QUE ESTE RELACIONADO CON categoriaID = 1 y categoriaID = 2 al mismo tiempo.
ES DECIR, QUIERO SABER QUE INMUEBLE TIENE PISCINA Y ADEMAS TERRAZA, x ej.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:SELECT ??

Publicado por Isaias (5072 intervenciones) el 14/06/2007 19:34:30
No se comprende muy bien, pero, podria ser

WHERE categoriaID IN(1,2)

¿Que base de datos ocupas?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:SELECT ??

Publicado por beto (2 intervenciones) el 14/06/2007 22:43:47
SOLO QUIERO EL INMUEBLE QUE CUMPLA LAS CON LAS DOS CARACTERISTICAS. SI USO 'WHERE categoriaID IN(1,2)' OBTENGO LOS INMUEBLES CON LA CARACTERISTICA 1 POR UN LADO Y CON LA 2 POR EL OTRO.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:SELECT ??

Publicado por Isaías (5072 intervenciones) el 14/06/2007 23:37:59
Prueba asi

select ID, inmuebleID
from tutabla T1 JOIN
(SELECT ID, inmuebleID
WHERE categoriaID = 1) AS T2
ON T1.inmuebleID = T2.inmuebleID
WHERE categoriaID = 2
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar