mysql - How to get unique number of rows from the secondary table -


create table pro_category (id primary key, product_id int, category_id int) insert pro_category (1, 1, 1) insert pro_category (1, 1, 2) insert pro_category (1, 2, 1) insert pro_category (1, 2, 1) 

how unique number of rows secondary table (e.g. in above case there 2 product id's involved answer of 2).

using count(distinct)

select count(distinct product_id) pro_category 

Comments

Popular posts from this blog

c# - Is it possible to remove an existing registration from Autofac container builder? -

asp.net - RadAsyncUpload in code behind, how to? -