Ver Mensaje Individual
  #18 (permalink)  
Antiguo 17/09/2004, 06:13
Atzeneta
 
Fecha de Ingreso: junio-2004
Ubicación: Castellón, España
Mensajes: 98
Antigüedad: 19 años, 11 meses
Puntos: 0
Si no soporta consultas anidadas no te servirá el anterior código, entonces tendrás que construir el sql de la siguiente forma:

'Aquí damos el valor inicial del sql.
sql = "SELECT tabla1.Id, tabla1.Nombre FROM tabla1"

'En el For vamos creando la clausula FOR, la WHERE
C_For = ""
C_Where = ""
IFor = 1
For IFor=1 to I_valores
C_For = C_For & ", Tabla2 as cns_" & IFor
if IFor=1 then
C_Where = " WHERE tabla1.id1=cns_" & IFor & ".id2"
else
C_Where = C_Where & " AND tabla1.id1=cns_" & IFor & ".id2"
end if
C_Where_2 = C_Where_2 & " AND cns_" & IFor & ".dato2='" & valores(IFor) & "'"
Next

sql = sql & C_For & C_Where & C_Where_2