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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:21:57+00:00 2026-05-30T16:21:57+00:00

I have table: user_id | song_id| points ——–|—————- 2 | 1 | 0 2

  • 0

I have table:

user_id | song_id| points
--------|----------------
  2     |  1     |  0
  2     |  2     |  1
  2     |  3     |  2
  2     |  4     |  3
  2     |  5     |  4

And I need to check if the user have changed the points value.
Therefore it should be something like:

while ($row = mysql_fetch_array($query)) {
    $userID = $row['user_id'];
    $songID = $row['song_id'];
    $points = $row['points'];
if($songID-$points==1){
 echo $userID."<br>";

}

But this will print out every occasion of userID where the song-id – points=1.

I need to print out only these user_id’s that have all the values =1 and the username must echo’d only once.

EDIT:

SELECT DISTINCT user_id WHERE (song_id - points) = 1

This is half way there. This echo’s user_ids’ where the song_id – points = 1, but if the user is reordered (i use jQuery sortable) the list, then there can be some rows that is “song_id – points = 1”.

My script must echo only these user_id-s, where users every song_id – points = 1, not only one

  • 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-30T16:21:59+00:00Added an answer on May 30, 2026 at 4:21 pm

    You can first filter the users which has modified point values:

    SELECT DISTINCT user_id FROM table
    WHERE (song_id - points) != 1
    

    Then you can use fetch the users which doesn’t fit the above condition:

    SELECT DISTINCT user_id FROM table
    WHERE user_id NOT IN (
      SELECT DISTINCT user_id FROM table
      WHERE (song_id - points) != 1
    )
    

    According to your last edit this last SQL statement might work.

    You can check a working example.

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

Sidebar

Related Questions

Let's say I have a table that has user_id, date, score, and every user
I have a table of purchases containing a user_id and a date_of_purchase. I need
I have a table: user_qualifications: id user_id type title description I need to get
I have an Table USER (USER_ID, PASSWORD, NAME, ...) and an Table ACCESS_ROLES for
I have a table user (id, name ...) and user_emails (id, user_id, email_id, type)
So i have MySql and i have a table user with a user_id column
I have a table that contains intervals: CREATE TABLE tbl ( user_id: INTEGER, start:
I have a table of userdata that includes user ID and category IDs. I
I have a table with a auto-incremented primary key: user_id. For a currently theoretical
I have a table that contains id, created, user_id. I'm wondering if there is

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.