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
Post a Comment