Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-28-2012, 05:24 PM   PM User | #1
iT3d.
New Coder

 
Join Date: May 2012
Posts: 45
Thanks: 7
Thanked 1 Time in 1 Post
iT3d. is an unknown quantity at this point
Set PHPbb Thread View Numbers

Code:
UPDATE  `phpbb_topics` SET  `topic_views` =  '145' WHERE  `topic_id` =1
This is the code you get when manually editing a single post's view count in phpMyAdmin, and the topic ID is 1.

What I am needing to do, is to edit all posts at once, and instead of setting the views of every topic to 145, I want to add 145 to every thread's number of topic views. Make sense?

I know that

Code:
UPDATE  `phpbb_topics` SET  `topic_views` =  '145' WHERE  `topic_id` >=1
Would set the topic views of all posts to 145.

SO my question, is there (and if so, what is) the MySQL command to increase the number of topic views by a number I specify rather than to set the number of topic views on all threads to a specific number.
iT3d. is offline   Reply With Quote
Old 06-28-2012, 05:33 PM   PM User | #2
Keleth
Senior Coder

 
Join Date: Jun 2008
Location: New Jersey
Posts: 2,354
Thanks: 45
Thanked 247 Times in 244 Posts
Keleth is on a distinguished road
Well, just like how with any other programming language a variable set to itself + an amount would work, the same applies here

Code:
UPDATE  `phpbb_topics` SET  `topic_views` = topic_views + 145
As topic_views is (or should be) a numeric type (int I'm guessing?), don't quote it... 145 != '145'
Keleth is offline   Reply With Quote
Users who have thanked Keleth for this post:
iT3d. (06-28-2012)
Old 06-28-2012, 05:39 PM   PM User | #3
iT3d.
New Coder

 
Join Date: May 2012
Posts: 45
Thanks: 7
Thanked 1 Time in 1 Post
iT3d. is an unknown quantity at this point
Quote:
As topic_views is (or should be) a numeric type (int I'm guessing?), don't quote it... 145 != '145'
I just did a manual edit and copied everything phpMyAdmin returned to me - but thanks for the input ill remember that for the future.


That worked! I'l have to bring in a WHERE to specify specifics but that worked wondefully thank you!
iT3d. is offline   Reply With Quote
Old 06-28-2012, 07:39 PM   PM User | #4
guelphdad
Super Moderator


 
guelphdad's Avatar
 
Join Date: Mar 2006
Location: St. Catharines, Ontario Canada
Posts: 2,629
Thanks: 4
Thanked 147 Times in 138 Posts
guelphdad will become famous soon enoughguelphdad will become famous soon enough
well you said you wanted it to apply to all topic_views so you wouldn't need a WHERE clause to affect all topic_views.

you shouldn't quote numeric values no, but mysql allows you to be sloppy and do so. I'd advise not to get in that habit though.
guelphdad is offline   Reply With Quote
Old 06-29-2012, 10:20 PM   PM User | #5
iT3d.
New Coder

 
Join Date: May 2012
Posts: 45
Thanks: 7
Thanked 1 Time in 1 Post
iT3d. is an unknown quantity at this point
Quote:
Originally Posted by guelphdad View Post
well you said you wanted it to apply to all topic_views so you wouldn't need a WHERE clause to affect all topic_views.
To boost the views as a whole, but I don't want everything to appear to uniform in the end so i'll have to make use of a WHERE to differentiate and make the stats look legit.

Quote:
Originally Posted by guelphdad View Post
you shouldn't quote numeric values
Good to know, a definite note hath been made of this. Thank you.
iT3d. is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:38 PM.


Advertisement
Log in to turn off these ads.