Good afternoon in advance greeting and thanks for your time I am in a company with a system "semi open" so to speak that only lets me manipulate the select, from
but not the where
of my queries this brings as a consequence, information that we do not need would be something like articulo
with its fields and one of them is a field compuesto
this field is worth 1
or 2
if 2
is a composite article everything would be very easy If I put in my query a where compuesto = 2
but remember that I do not handle that and therefore brings me everything that integrates that product, let's talk about a grill for example, it tells me the salt, the sauce, the pepper, everything related would that product have any solution with a condition if
before select
? this is the complete query and remember the where
is not placed by me but by the system code
select
articulo.garantia,
articulo.campo1,
articulo.campo2,
articulo.campo3,
articulo.origen,
articulo.referencia,
operti.tipodoc,
operti.codcliente,
operti.nombrecli,
operti.rif,
operti.nit,
operti.escredito,
operti.estatusdoc,
operti.vence,
operti.orden,
operti.estacion,
operti.horadocum,
operti.ampm,
operti.factorcamb,
operti.contacto,
operti.documento,
operti.emision,
operti.totalfinal,
operti.totbruto,
operti.totdescuen,
operti.totneto,
operti.totimpuest,
operti.totpagos,
operti.factorcamb,
monedas.nombre as nombremoneda,
monedas.simbolo as simbolomoneda,
opermv.impu_mto,
opermv.codhijo,
operti.vuelto,
operti.dsctolinea,
operti.dsctoend2,
operti.dsctoend1,
operti.notas as opertinotas,
cliempre.direccion,
cliempre.email,
cliempre.telefonos,
cliempre.numerofax,
cliempre.perscont,
opermv.codigo,
opermv.nombre as nombre1,
opermv.notas,
opermv.unidad,
opermv.timpueprc,
opermv.preciofin,
opermv.cantidad,
opermv.montoneto,
opermv.vendedor,
opermv.preciounit,
opermv.dsctounit,
opermv.montototal,
opermv.dsctoendm,
opermv.tallas,
opermv.colores,
opermv.codhijo,
opermv.agrupado,
opermv.imp_nacional,
opermv.imp_producc,
operclit.tardebmto,
operclit.tardebnom,
operclit.tardebnum,
operclit.mtotarjeta,
operclit.bancotar,
operclit.nrotarjeta,
operclit.bcocheqmto,
operclit.bcocheqnom,
operclit.bcocheqnro,
operclit.otrotipo,
operclit.otroreferencia,
operclit.efectivo,
operclit.ncredito,
operclit.monto,
operti.sinimpuest,
grupos.codigo,
grupos.nombre,
listvend.nombre
from
opermv
left join operti on (opermv.agencia = operti.agencia)
and (opermv.tipodoc = operti.tipodoc)
and (opermv.documento = operti.documento)
left join cliempre on (operti.codcliente = cliempre.codigo)
left join listvend on (operti.vendedor = listvend.codigo)
left join operclit on (operti.documento = operclit.documento and operclit.referencia=' ')
and (operti.tipodoc = operclit.tipodoc)
left join grupos on (opermv.grupo = grupos.codigo)
left join articulo on (opermv.codigo = articulo.codigo)
left join monedas on (monedas.codigo = if(operti.moneda='','000',operti.moneda))
where opermv.id_empresa='HOTE21' and opermv.agencia='001' and opermv.tipodoc='FAC' and opermv.documento='*0000014' order by opermv.pid