Facebook  Twitter 

SMFHacks.com

+- +-

SMFHacks.com

+- User Information

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Forum Stats

Members
Total Members: 11857
Latest: FranckHertz09
New This Month: 9
New This Week: 5
New Today: 3
Stats
Total Posts: 37439
Total Topics: 6592
Most Online Today: 79
Most Online Ever: 2482
(April 09, 2011, 06:02:45 pm)
Users Online
Members: 1
Guests: 80
Total: 81

Author Topic: Complicated MySQL Query  (Read 395 times)

0 Members and 1 Guest are viewing this topic.

Offline shuban

  • Hero Member
  • *****
  • Posts: 503
    • View Profile
    • Biology Forums - For All Your Science Needs
Complicated MySQL Query
« on: January 10, 2017, 11:30:26 pm »
Let's pretend we have a table:

ID      col1      col2
1      33      2
2      52      78

I want to sum col1 and col2 and replace the value of col1 with that sum:

ID      col1              col2
1      35                         2
2      130                      78

Could you tell me the query I'd use to do this

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 13845
    • View Profile
Re: Complicated MySQL Query
« Reply #1 on: January 11, 2017, 08:06:02 am »
Backup first
Something like
Update tablename set col1 =(COL1 + COL2)
Get your Forum Ranked! at http://www.forumrankings.net - find out how your forum compares with others! Also contests/promotions for verified sites.

Offline shuban

  • Hero Member
  • *****
  • Posts: 503
    • View Profile
    • Biology Forums - For All Your Science Needs
Re: Complicated MySQL Query
« Reply #2 on: January 11, 2017, 02:52:03 pm »
Worked, thanks

 

Related Topics

  Subject / Started by Replies Last post
1 Replies
2361 Views
Last post January 31, 2008, 05:28:27 pm
by SMFHacks
0 Replies
1341 Views
Last post October 12, 2010, 04:49:10 pm
by mxcape21
11 Replies
3640 Views
Last post February 06, 2012, 03:44:53 am
by spikeweb
4 Replies
2375 Views
Last post July 11, 2016, 11:50:54 am
by shuban
1 Replies
1627 Views
Last post August 17, 2016, 05:12:18 pm
by SMFHacks

+- Recent Topics

smf Gallery pro and video Plugin upload from Iphone by SMFHacks
January 20, 2017, 09:22:50 am

Download link doesn't work on Ipads by shuban
January 17, 2017, 11:15:23 am

Nochex by shuban
January 17, 2017, 11:12:34 am

Font Size In Latest Badges Awarded On Main Index by SMFHacks
January 12, 2017, 07:12:38 pm

Tracking members by SMFHacks
January 12, 2017, 09:56:50 am

How much does it cost to get an upgrade for this Mod? by shuban
January 11, 2017, 04:06:30 pm

Complicated MySQL Query by shuban
January 11, 2017, 02:52:03 pm

How do I make the product description PHP ready? by shuban
January 10, 2017, 07:14:39 pm

Moving over to https by SMFHacks
January 10, 2017, 07:00:22 pm

observations & suggestions by climber
January 01, 2017, 07:51:30 pm

Powered by EzPortal