Facebook  Twitter 

SMFHacks.com

+- +-

SMFHacks.com

+- User Information

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

+- Forum Stats

Members
Total Members: 11897
Latest: NCorleone1
New This Month: 15
New This Week: 3
New Today: 1
Stats
Total Posts: 37802
Total Topics: 6655
Most Online Today: 93
Most Online Ever: 2482
(April 09, 2011, 06:02:45 pm)
Users Online
Members: 0
Guests: 67
Total: 67

Author Topic: Complicated MySQL Query  (Read 707 times)

0 Members and 1 Guest are viewing this topic.

Offline shuban

  • SMF Store Customer
  • Hero Member
  • *****
  • Posts: 577
    • 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: 13994
    • 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

  • SMF Store Customer
  • Hero Member
  • *****
  • Posts: 577
    • 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
2414 Views
Last post January 31, 2008, 05:28:27 pm
by SMFHacks
0 Replies
1373 Views
Last post October 12, 2010, 04:49:10 pm
by mxcape21
4 Replies
2534 Views
Last post July 11, 2016, 11:50:54 am
by shuban
1 Replies
1730 Views
Last post August 17, 2016, 05:12:18 pm
by SMFHacks
12 Replies
691 Views
Last post February 10, 2017, 08:56:57 am
by GeorG

+- Recent Topics

Extreme coding help by SMFHacks
March 23, 2017, 07:37:58 pm

Permissions system by Darkshadow
March 23, 2017, 09:26:41 am

Aprove link by Darkshadow
March 23, 2017, 09:23:04 am

Downloads folderm by davejo
March 21, 2017, 11:33:14 am

use on a sandbox pre-production? by drewactual
March 19, 2017, 10:22:13 pm

Delete ratings from profile? by yameth
March 17, 2017, 03:32:17 am

tiny url error by SMFHacks
March 16, 2017, 03:49:25 pm

Daughter menus by KevinK
March 16, 2017, 04:02:43 am

[Mod] Tagging System by Web Presence Consulting
March 15, 2017, 08:50:21 pm

audio into downloadsystem by johannes47
March 14, 2017, 11:15:33 am

Powered by EzPortal