Jump to content
The forums will be going offline for an extended maintenance period at 1400hrs GMT on 19th June 2025. The number of hours for this downtime is intentionally not advertised due to the nature of these upgrades. ×
  • 0

Matching values using SQL with multiple tables


Nyaniverse

Question


  • Group:  Members
  • Topic Count:  13
  • Topics Per Day:  0.02
  • Content Count:  51
  • Reputation:   35
  • Joined:  09/09/23
  • Last Seen:  

I'm trying to match the points to their names and aid on another table, but somehow the points are not going to their assigned aid, any clues on how to properly set it?

                    .@sql$ = " SELECT `account_id`,`value` "
                             + " FROM `acc_reg_num`"
                             + " WHERE `key` = '#s_alltime' "
                             + " AND `value` >= 1"
                             + " ORDER BY `value` DESC LIMIT 20";
                    query_sql(.@sql$,.@aid,.@total);
                    query_sql("SELECT `aid`,`name` FROM `test_db`",.@said,.@name$);
                    //comparing who's going to be in the ranking
                    for(.@i = 0; .@i < getarraysize(.@aid); .@i++)
                        if(inarray(.@said[0],.@aid[.@i]) != -1){
                            .@all_time$[.@i] = .@name$[inarray(.@aid[0],.@said[.@i])];
                            .@all_time[.@i] = .@total[inarray(.@aid[0],.@said[.@i])];
                        }
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  13
  • Topics Per Day:  0.02
  • Content Count:  51
  • Reputation:   35
  • Joined:  09/09/23
  • Last Seen:  

Solved.

For anyone looking the solution, it's using INNER JOIN on SQL

					.@sql$ = " SELECT `acc_reg_num`.`value`,`streamer_db`.`name`"
							 + " FROM `acc_reg_num`"
							 + " INNER JOIN `streamer_db`"
							 + " ON `acc_reg_num`.`account_id` = `streamer_db`.`aid`"
							 + " WHERE `acc_reg_num`.`key` = '#s_alltime' "
							 + " AND `acc_reg_num`.`value` >= 1"
							 + " ORDER BY `acc_reg_num`.`value` DESC LIMIT 20";

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...