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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:18:30+00:00 2026-05-31T04:18:30+00:00

So, I thought I was getting pretty good at MySQL until I ran into

  • 0

So, I thought I was getting pretty good at MySQL until I ran into this idea:

I have a table logging “votes” (aptly named votes) with these fields:

  • id: The vote’s unique ID.
  • user: Unique User ID of the person who voted
  • item: ID of item they’re voting on
  • vote: The vote they cast SET(‘up’,’down’)

Now, I’m trying to come up with an SQL way to find users whose only votes are downvotes. I know of a way to write it procedurally in php after querying most of the data out of the table but it seems really, really inefficient to do that way when only a few queries could find this out.

Ideally I want my result to just be a list of users who have 0 upvotes (as being in the table means they have voted, so they only downvote) and maybe the number of downvotes they’ve cast.

Any ideas on how I should approach this?

  • 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-31T04:18:31+00:00Added an answer on May 31, 2026 at 4:18 am
    SELECT user, SUM(IF(vote='down',1,0)) AS numDownVotes
    FROM votes
    GROUP BY user
    HAVING SUM(IF(vote='up',1,0))=0   -- 0 upvotes
       AND SUM(IF(vote='down',1,0))>0 -- at least 1 downvotes
    

    I can’t help but feel there’s a neat GROUP BY user, vote way to do this though.

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

Sidebar

Related Questions

I'm a bit new to Maven. I thought I was getting a pretty good
i thought i getting the hang of Cocoa memory management, but apperently i have
I am getting a web host and i have projects with teammats. I thought
I thought I had a pretty good grasp of the difference between the is
I thought this would be pretty academic but its not. I'm trying to traverse
I thought this would be a pretty common question to look for in Google
I have written what I thought to be a pretty solid Linq statement but
So I have this pretty large XML file (40MB) that I'll have to repeatedly
I thought I had my conversion to fragments pretty well done until I rotated
I'll start by I have no idea on the terminology on this or if

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.