Jump to content

Archived

This topic is now archived and is closed to further replies.

jmaccs64

Whats wrong here?

Recommended Posts

I am new at this....can someone please tell me what is wrong with this statement?
Thanks


[code]SELECT users.username, users.vote_count, surpool06.surpool_username, surpool06.surpool_team
FROM users
INNER JOIN surpool06
ON users.username = surpool06.surpool_username
UPDATE
users SET vote_count = IF(surpool_team = 'Bears',vote_count-1,vote_count)[/code]

Share this post


Link to post
Share on other sites
You can't put an UPDATE there...

Share this post


Link to post
Share on other sites
I'm not really sure what you're trying to do....

Share this post


Link to post
Share on other sites
Join two table users and surpool06

then based on a field in surpool06 subtract 1 from vote count on users...

Does that make sense?
Thanks

Share this post


Link to post
Share on other sites
Provided you're using a recent version of MySQL, UPDATE statements support multiple tables (UNTESTED):
[code]
UPDATE users
INNER JOIN surpool06
ON users.username = surpool06.surpool_username
SET vote_count = IF(surpool_team = 'Bears',vote_count-1,vote_count)
[/code]

Share this post


Link to post
Share on other sites
Thanks...that works...

but there is one problem...

Although each vote has a unique identifier.. if the person picks the same team twice in the same week, it only subtracts 1, from their vote count, when it should subtract 2....Is there any way to remedy this?

Share this post


Link to post
Share on other sites
Sounds like you'd need a GROUP BY, and subtract the count.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.