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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:05:54+00:00 2026-05-28T17:05:54+00:00

I have the follow query: SELECT `peers`.uid, `user`.userid FROM `peers`, `user` WHERE `user`.userid =

  • 0

I have the follow query:

SELECT `peers`.uid, `user`.userid FROM `peers`, `user` WHERE `user`.userid = `peers`.uid

the FF. is the result of the query

userid,uid
1,1
1,1
1,1
3,3
96,96
96,96

To update the result of that, I have the ff query setup:

UPDATE `user`
   INNER JOIN (    
   SELECT `peers`.uid, `user`.userid FROM `peers`, `user` WHERE `user`.userid = `peers`.uid
       ) AS my_current_select ON `user`.userid = my_current_select.userid
   SET `user`.credits = `user`.credits + 0.25

However, the update query update only 3 times, each plus once 0.25 credits into userID 1,3,96

This is not what I want. I want to uniquely add 0.25 credits into each row result of the query.
For example:

UID 1: UID1.credit = UID1.credit + 0.25 * 3 
UID 3: UID3.credit = UID3.credit + 0.25 * 1 
UID 3: UID96.credit = UID96.credit + 0.25 * 2

How can I achieve this result?

  • 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-28T17:05:56+00:00Added an answer on May 28, 2026 at 5:05 pm

    Perhaps change your inner query to:

    SELECT `user`.userid, COUNT(`peers`.uid) as count 
    FROM `peers`, `user` 
    WHERE `user`.userid = `peers`.uid 
    GROUP BY `user`.userid
    

    to get:

    userid,count
    1,3
    3,1
    96,2
    

    And then in your master query do:

    UPDATE `user`
       INNER JOIN (    
       SELECT `user`.userid, COUNT(`peers`.uid) as count 
        FROM `peers`, `user` 
        WHERE `user`.userid = `peers`.uid 
        GROUP BY `user`.userid
           ) AS my_current_select ON `user`.userid = my_current_select.userid
       SET `user`.credits = `user`.credits + 0.25*my_current_select.count
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have follow query: SELECT tbl_yaca_sites.`id_site` FROM `tbl_yaca_sites` INNER JOIN `tbl_relation` ON tbl_relation.id_website = tbl_yaca_sites.id_site
I have the follow SQL query statement: SELECT subject, sender_list, date, uid FROM messages
I have the follow query: SELECT pro.* FROM tb_AutProposta pro, tb_AutParcelamento par WHERE pro.id
I have a record that came from the follow linq query: using (var context
I have the follow query selecting stuff from a database: mysql_query(SELECT * FROM categories
Suppose I have a SQL query that looks like this: SELECT fName from employees
I have some simple query: SELECT * FROM table You all know the result:
I have a query like this: SELECT c.id, c.name, f.name FROM companies c INNER
I have the cursor with the query statement as follows: cursor.execute(select rowid from components
This is a follow on from another question i made I have this query

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.