Comments - What Join
Content reproduced on this site is the property of its respective owners,
and this content is not reviewed in advance by MariaDB. The views, information and opinions
expressed by this content do not necessarily represent those of MariaDB or any other party.
After wrestling with this for HOURS, I finally came up with something that functions in the desired manner:
select *, SUM(Cantidad) from (select CatArticulos.ArticuloId, ArticuloNombre, ArticuloCodigo, ArticuloUnidad, ArticuloMin, ArticuloMax, ArticulosDisponibles, Cantidad, ArticuloDesc from CatArticulos left join ContenidosDeModelos on CatArticulos.ArticuloId=ContenidosDeModelos.ArticuloId where ModeloID = {$ModeloRec{'ModeloID'}} and ArticuloDeshabilitado = 'N' and ( ArticuloPara = 'Ordenes' or ArticuloPara = 'Todos' ) union all select ArticuloId, ArticuloNombre, ArticuloCodigo, ArticuloUnidad, ArticuloMin, ArticuloMax, ArticulosDisponibles, 0.0 as Cantidad, ArticuloDesc from CatArticulos) group by ArticuloId order by ArticuloCodigo
This does what I want, but I feel that there must be a more elegant way of writing it.
Any suggestions??
Richard