shany0786 8 Junior Poster in Training

i have table category_master(cat_id(pk),category_name,active)

and sub_category table with fields(sub_cat_id(pk),category_id,sub_category_name,active)

now what i want is count number of active sub categories having value=1 if this count is 0 then update active=0 in category_master table

i have been trying this but no go,can anyone help me in this?

SELECT active,category_id, count( * ) AS 'Cnt'
FROM gy_sub_category
WHERE active =0 if (Cnt='0') then set active=1

trying this but no success how can i achieve above??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.