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 7789041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:10:22+00:00 2026-06-01T21:10:22+00:00

I Have 2 tables in my db that each have a column named Catergory.

  • 0

I Have 2 tables in my db that each have a column named Catergory.

Categories Table -
id | category_name
1  : basic
2  : midlevel
3  : highlevel
4  : profesional

Product Table - 
id | product | category_name
1  : adsl 1G : basic
2  : adls 2G : midlevel
3  : adsl 3G : highlevel
4  : adsl 4G : profesional

When i update the *category_name* in the categories table i would like to change it in the Products table as well, but i am not sure on how to do this.

I couldnt find and answer because i dont know how to phrase it correctly.

Any help would be appreciated.

What my update.php looks like now:

     db_update("UPDATE category SET 
    `category_name` = '".$_POST['category_name']."'
     WHERE category_id = '".$id."'");

what is should look like:???

{code here}

Note: “FIXED – I forgot to send my old value to the save.php file so the $id never knew what to update”.

  • 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-06-01T21:10:23+00:00Added an answer on June 1, 2026 at 9:10 pm

    You could just run two queries changing both names:

    <?php
    mysql_query("UPDATE categories SET category_name='" . $catname . "' WHERE category_name='basic'");
    mysql_query("UPDATE product SET category_name='" . $catname . "' WHERE category_name='basic'");
    ?>
    

    If you want to do it in one string you can do this with multiple queries, a joined query or a stored procedure.

    Multiple queries in one string:

    <?php
        mysql_query("
            mySqlQuery(UPDATE categories SET category_name='" . $catname . "' WHERE category_name='basic';)
            mySqlQuery(UPDATE product SET category_name='" . $catname . "' WHERE category_name='basic';)
        ");
    ?>
    

    Joined query:

    <?php
    mysql_query("
        UPDATE `product`,`categories`
        SET `product`.`category_name` = '" . $catname . "',
            `categories`.`category_name` = '" . $catname . "'
        WHERE `items`.`id` = '" . $catname . "'
    ");
    ?>
    

    If none of the above work I suggest changing your tables so there isn’t a matching name but a matching ID.

    You’ll get the following:

    Categories Table -
    id | category_name
    1  : basic
    2  : midlevel
    3  : highlevel
    4  : profesional
    
    Product Table - 
    id | category_ID | product
    1  : 1           : adsl 1G
    2  : 2           : adls 2G
    3  : 3           : adsl 3G
    4  : 3           : adsl 4G
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 joined tables, each one has a primary key column named id.
I have Product table that have category1 and category2 field, and each field contain
I have a table that has three different date columns, so I set each
Here is the problem: I have two columns in a table that, for each
We have a table that is used for assessment-values in our tool where each
I have a table full of items that each have a unique ItemID .
I have a table that has multiple payments occuring on different dates each month.
I have a table that assign elements to groups. Each element can exist in
I have periods table that has start_at:datetime end_at:datetime . Because each period begins and
Background I have a dimension table that has a single record for each day.

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.