MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 21st, 2000, 11:41 PM
weldonj weldonj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2000
Posts: 41 weldonj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 47 m 2 sec
Reputation Power: 8
I just found out that MySql currently does not support updating one table based upon values in another table (this was hard for me to believe because I'm fairly new to this, and I just assumed this would be supported).

So, now I have to get around it. i've seen references to being able to get aroung this problem but have never seen it explained.

I have one table TOP10, that has people's votes for their top10 (login, number1, number2, number3, etc). The other table CHOICES has a list of the choices for the Top10. Basically, I want to come up with an aggregate top10 by assigning points to each of the choices in CHOICES Based upon the votes in TOP10. I was hoping to just do: update choices set choices.points=choices.point+10 where TOP10.number1=choices.choices; and then repeat this for numbers2-9. But I can't do this, so how do I get around it? Any suggestions would be appreciated? And if you have a generic solution to this problem please feel free to post that, as all I really need to do is get around the problem of not being able to update based upon values in two tables.

Thank you.

Reply With Quote
  #2  
Old October 22nd, 2000, 12:06 AM
weldonj weldonj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2000
Posts: 41 weldonj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 47 m 2 sec
Reputation Power: 8
one more thing. I'm using mysql 3.22.25 so I can't create temporary tables from select statements.

Reply With Quote
  #3  
Old October 22nd, 2000, 07:55 AM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 13
Send a message via AIM to rod k
This should be relatively simple but it would help to know how you have your form set up.

Also, do you want to update the choices table whenever a vote is processed or periodically?

Reply With Quote
  #4  
Old October 22nd, 2000, 12:02 PM
weldonj weldonj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2000
Posts: 41 weldonj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 47 m 2 sec
Reputation Power: 8
My form already is dynamic in the sense that the list where they vote for each of their top10 is pulled from the choices table. There is a way to enter a choice not listed but then it is added to the choice table. All the voter sees is a top10 tabe with drop down menus with a list of each of the choices.

<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by rod k:
This should be relatively simple but it would help to know how you have your form set up.

Also, do you want to update the choices table whenever a vote is processed or periodically?
[/quote]

Reply With Quote
  #5  
Old October 22nd, 2000, 06:40 PM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 13
Send a message via AIM to rod k
Let me rephrase. How are the selections being passed? IOW, what variable name(s) are you using or are you using an array?

Reply With Quote
  #6  
Old October 22nd, 2000, 11:32 PM
weldonj weldonj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2000
Posts: 41 weldonj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 47 m 2 sec
Reputation Power: 8
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by rod k:
Let me rephrase. How are the selections being passed? IOW, what variable name(s) are you using or are you using an array?[/quote]

WHen they vote I am using an array. It's called team[0] to team[9]. I then take these values and put them into the database. The database has variables team1-team10. I think I see where you are headed to update the scores with each vote instead of doing it at the end like I am trying to do now.

Reply With Quote
  #7  
Old October 23rd, 2000, 07:49 AM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 13
Send a message via AIM to rod k
You should set up your Top10 table like this:

userid | teamid | rank

This way each userid would have ten entries. Use an inverse for storing the rank (ie if the ranked a team #1 then give it a score of 10 in rank).

Now, to get the ranks you can do this:

select sum(rank) as total from top10 group by teamid;

to store this in your choices table, assuming that the teamid column is unique, you can do this instead:

replace into choices (teamid,score) select teamid,sum(rank) from top10 group by teamid;


Reply With Quote
  #8  
Old October 25th, 2000, 09:48 PM
weldonj weldonj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2000
Posts: 41 weldonj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 47 m 2 sec
Reputation Power: 8
Thanks!

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Getting around not Updating across multiple tables


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway