mercredi 17 février 2016

Sqlite select statement from 2 tables

I have two tables: Products and CategoryProducts.
CategoryProducts contains PrdID and Category.
Products contains PrdID, Barcode, Url.

I have Products.Barcode value, for example 111111.

Need to select all Products.Url with the same Category, as this item's Category.

Having Products.PrdID, i can get all needed PrdID's from CategoryProducts like this:

select distinct c1.PrdID from CategoryProduct_MM c1 where c1.CategoryID in (select c2.CategoryID from CategoryProduct_MM c2 where c2.PrdID = 175)

Aucun commentaire:

Enregistrer un commentaire