Comments - What Join

10 years, 1 month ago Richard Couture

The closest that I have been able to get thus far is with

select Cantidad, ModeloID, CatArticulos.ArticuloID, ArticuloCodigo, ArticuloNombre, ArticuloDesc, ArticulosDisponibles, ArticuloMin, ArticuloMax, ArticuloUnidad from ContenidosDeModelos right outer join CatArticulos using (ArticuloID) where ArticuloDeshabilitado = 'N' and ( ArticuloPara = 'Ordenes' or ArticuloPara = 'Todos' ) order by ArticuloCodigo";

The problem being that if a record exists in both of the tables, it gives me 2 records rather than combining the 2 as 1 record.

Since the table ContenidosDeModelos can have 50 records for the same ArticuloID but with different ModeloID, I can get 50 reords for the same ArticuloID rather than the 1 record for the ModeloID that interests me, if it exists, or the default record in CatArticulos for the ArticuloID when no ModeloID exists for that ArticuloID.


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.