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

  • Home
  • SEARCH
  • 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 6358307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:20:53+00:00 2026-05-24T23:20:53+00:00

I have a mysql table called books that has a votes column, and another

  • 0

I have a mysql table called books that has a “votes” column, and another table called series which has a “total_votes” column. The votes column tracks votes for an individual book, while the total_votes column is a tabulation of all votes for all books within a series.

In the administration section, an admin can manually change the number of votes an individual book has. I want to create a mysql trigger so that whenever a vote is changed, the difference between old vote value and new vote value is reflected in the total_votes column. For example, if Book A has 10 votes and Series 1 has a total of 100 votes, when I change the vote count of Book A to 5, I want the total_vote count of Seris 1 to be 95.

I understand how to make a basic trigger, but I’m not sure how update the Series table with the difference between the old and new vote values.

TIA.

  • 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-24T23:20:55+00:00Added an answer on May 24, 2026 at 11:20 pm

    Don’t worry about the difference, just update based on a new sum. For example:

    (Not sure if this is the exact MySql syntax)

    update series
    set total_votes = sum(select votes from books b where b.seriesid = seriesid)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a date and time column in my mysql table called start_date and
I have a MySQL database called bookfeather. It contains 56 tables. Each table has
I have a MySQL table called bb_posts used by a bbPress forum. It has
I have a MySQL table called items that contains thousands of records. Each record
In MySQL table, I have a field called Tag, which may include multiple comma-delimited
I have a column with datetime datatype called 'updated_at' in a mysql table,where i
I have a legacy MySQL table called lnk_lists_addresses with columns list_id and address_id .
I have a nullable DateTime column in my SQL Server 2005 table called DateTimeDeleted.
I have a mysql table that relies on the unix epoch time stamp equivalent
I have a MySQL table that will only have one row. What should my

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.