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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:59:16+00:00 2026-05-25T20:59:16+00:00

I have three tables so I can display separate tables and keep track of

  • 0

I have three tables so I can display separate tables and keep track of different things.

How do I make ‘pull_qty” in CARTONS_PULLED and ‘add_qty’ in CARTONS_ADDED update ‘qty’ in CARTONS _CURRENT?

When I create a new Part Number with a quantity it inserts into CARTONS_CURRENT.

Now I need to update the ‘qty” in CARTONS_CURRENT with adds and pulls from the two other tables? the ‘part_no’ is the primary key and is always the reference to update.

Here are my tables:

DATABASE NAME: _hero 

TABLE NAME:  CARTONS_CURRENT
+--------------+--------------+--------+--------+-------------------+------------+
| Column       |  Type        |  Null  |  Key   |  Default          |  Extra     |
+--------------+--------------+--------+--------+-------------------+------------+
| orig_time    | timestamp    |  No    |        | CURRENT_TIMESTAMP |            |
| type         | text         |  No    |        |                   |            |
| part_no      | varchar(20)  |  No    |  Prim  |                   |            |
| description  | varchar(75)  |  No    |        |                   |            |
| count        | varchar(2)   |  No    |        |                   |            |
| size         | varchar(30)  |  No    |        |                   |            |
| min          | int(7)       |  No    |        |                   |            |
| max          | int(7)       |  No    |        |                   |            |
| qty          | int(8)       |  No    |        |                   |            |
+--------------+--------------+--------+--------+-------------------+------------+

TABLE NAME:  CARTONS_ADDED
+--------------+--------------+--------+--------+-------------------+------------+
| Column       |  Type        |  Null  |  Key   |  Default          |  Extra     |
+--------------+--------------+--------+--------+-------------------+------------+
| add_time     | timestamp    |  No    |  Prim  | CURRENT_TIMESTAMP |            |
| type         | text         |  No    |        |                   |            |
| part_no      | varchar(20)  |  No    |  Prim  |                   |            |
| add_type     | varchar(25)  |  No    |        |                   |            |
| add_qty      | int(8)       |  No    |        |                   |            |
| add_ref      | varchar(35)  |  No    |        |                   |            |
| add_by       | text         |  No    |        |                   |            |
| add_notes    | varchar(300) |  No    |        |                   |            |
+--------------+--------------+--------+--------+-------------------+------------+

TABLE NAME:  CARTONS_PULLED
+--------------+--------------+--------+--------+-------------------+------------+
| Column       |  Type        |  Null  |  Key   |  Default          |  Extra     |
+--------------+--------------+--------+--------+-------------------+------------+
| pull_time    | timestamp    |  No    |  Prim  | CURRENT_TIMESTAMP |            |
| type         | text         |  No    |        |                   |            |
| part_no      | varchar(20)  |  No    |  Prim  |                   |            |
| pull_type    | varchar(25)  |  No    |        |                   |            |
| pull_qty     | int(8)       |  No    |        |                   |            |
| pull_ref     | varchar(35)  |  No    |        |                   |            |
| pull_by      | text         |  No    |        |                   |            |
| pull_notes   | varchar(300) |  No    |        |                   |            |
+--------------+--------------+--------+--------+-------------------+------------+
  • 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-25T20:59:17+00:00Added an answer on May 25, 2026 at 8:59 pm

    You’d write triggers for the CARTONS_PULLED and CARTONS_ADDED tables which do the appropriate updates in CARTONS_CURRENT table. Ie something like

    CREATE TRIGGER Upd_Cartons_qty 
    AFTER INSERT ON CARTONS_ADDED FOR EACH ROW
    BEGIN
      UPDATE CARTONS_CURRENT SET qty = qty + NEW.add_qty WHERE part_no = NEW.part_no;
    END;
    

    if you want to add the value of add_qty to the CARTONS_CURRENT.qty when new record is inserted into CARTONS_ADDED.

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

Sidebar

Related Questions

I have three tables with 5 columns each. They can grow upto 15 rows
I have three tables. I have to retrieve the data using Linq statement. My
I have three tables (individuals, groups & recordlabels) and want use the information between
I have three tables of data: table: cars [10,000 rows] table: planes [2,000 rows]
I have three tables: Employee(EmployeeID,Fname,Lname...) ProjectHeader(ProjectID,LeadID,Status....) ProjectDetails(ProjectDetailsID,ProjectID....) Here's my current code: $get_projects = SELECT
I have three tables in a Mysql database - countries, cities and hotels. Their
I have three tables as shown in below image. Note: Lead column of projectheader
I have three tables Author, Book and AuthorBook. AuthorBook table only contains two foreign
I have three MySQL Tables: customers, persons, and dates_d customers and persons are related
I have three tables companies, products and prices. Companies hasMany Products Products hasMany Prices

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.