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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:00:40+00:00 2026-05-27T14:00:40+00:00

Right now I have a voting system on my website that stores all votes

  • 0

Right now I have a voting system on my website that stores all votes in a votes table. in votes table I have a field named item_name which contains id of article that was liked. All article information including it’s id is located in a stories table. In votes table each there is a field named vote_value which can be 1 and -1 and depending on what user put for vote (like / dislike).

I need to somehow sum up all records for certain article and if they sum up as 10 or more make article approved. To approve article I have a field in stories table which is named as showing it can have two values 0 – unproved 1 – approved. So somehow I need to make it so once an article gets 10 likes (as a sum of all records from votes table) set showing to 1 (showing is in a stories table).

Preferably without any queries, say make database check for sums of vote_value of article that has a showing = 0 (and ignore ones that have showing = 1, so less server resources are used) . I’m not sure if this is a lot to do for a server, maybe it’s not the most efficient way.

EDIT: Users can un-vote and change vote value if they like (e.g. they liked the post, but they can change it to unlike).

My Database Structure:

stories


enter image description here

votes


enter image description here

  • 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-27T14:00:41+00:00Added an answer on May 27, 2026 at 2:00 pm
    UPDATE stories SET showing = 1 WHERE id IN (SELECT id,  SUM (vote_value) as total_votes from votes  GROUP BY item_name WHERE total_votes  > 10)
    

    What I think will be efficient (depending on the amount of voting):

    When a vote is cast:

    Insert into votes set vote_value = '-1' where id = xx;
    UPDATE stories SET showing = 1 WHERE id IN (SELECT id,  SUM (vote_value) as total_votes from votes WHERE id=xx AND total_votes  > 10);
    

    That last one could be broken up with PHP, because this is a bit of a strange way of doing it.

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

Sidebar

Related Questions

I have voting system on my website, it stores each users vote in table
Right now I have a table called Campaigns that has many Hits, if I
Right now I have a base class for my pages which inherits System.Web.UI.Page and
Right now I have a database (about 2-3 GB) in PostgreSQL, which serves as
Right now I have an SSIS package that runs every morning and gives me
Right now I have a JSP page that allows to sort some items, when
Right now I have this SQL query which is valid but always times out:
Hey, I right now have a list of a struct that I made, I
right now I have a huge Solution in which we use javascript alerts via
Right now I have: Time.strftime(%I:%M%p) which gives me the hr:min AM/PM format which I

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.