Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6901247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:38:57+00:00 2026-05-27T07:38:57+00:00

I have the table categories : categories_id | categories_status | parent_id 1 1 0

  • 0

I have the table categories:

categories_id | categories_status | parent_id
     1                  1               0
     2                  1               0
     3                  0               1
     4                  0               2
     5                  1               1
     6                  0               2

How can i select and update the status of the categories where all child categories having status = 0 (in this example it’s just the categories_id 2)? I need to integrate this in PHP.

Thanks in advance,

Alex

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:38:58+00:00Added an answer on May 27, 2026 at 7:38 am
    update categories,
    (
      select parent_id, sum(categories_status) as cnt
      from categories
      where parent_id!=0
      group by parent_id
      having cnt=0 
    ) as child_cat
    set ? = ?   /* what do you want to update? */
    where categories.categories_id=child_cat.parent_id
    

    Likely you don’t have to use PHP, a SQL will do.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a main table categories like this categories_id | categories_status | parent_id 1
table categories (TABLE_CATEGORIES) ,which have fields: categories_id , parent_id table categories_description (TABLE_CATEGORIES_DESCRIPTION) which have
I have a table of categories. Each category can either be a root level
I have a Categories table in which each category has a ParentId that can
Greetings, fellow coders! I have this table that contains categories and subcategories (actually I
I have a table named categories like this: id int(11) NO PRI NULL auto_increment
I have a MySQL table like this: CREATE TABLE categories ( ID INT NOT
Ok now i have two table categories and subcategories like this Categories: id title
Of all the solutions i have seen for this they fall into 3 categories.
i have a table with 3 columns id,name and parent_id representing categories. The root

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.