Facebook  Twitter 

SMFHacks.com

+- +-

SMFHacks.com

+- User Information

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

+- Forum Stats

Members
Total Members: 11873
Latest: Herry Lewis
New This Month: 10
New This Week: 0
New Today: 0
Stats
Total Posts: 37597
Total Topics: 6619
Most Online Today: 87
Most Online Ever: 2482
(April 09, 2011, 06:02:45 pm)
Users Online
Members: 0
Guests: 53
Total: 53

Author Topic: Complicated MySQL Query  (Read 579 times)

0 Members and 1 Guest are viewing this topic.

Offline shuban

  • Hero Member
  • *****
  • Posts: 529
    • 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: 13913
    • 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: 529
    • 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
2383 Views
Last post January 31, 2008, 05:28:27 pm
by SMFHacks
0 Replies
1354 Views
Last post October 12, 2010, 04:49:10 pm
by mxcape21
4 Replies
2482 Views
Last post July 11, 2016, 11:50:54 am
by shuban
1 Replies
1667 Views
Last post August 17, 2016, 05:12:18 pm
by SMFHacks
12 Replies
455 Views
Last post February 10, 2017, 08:56:57 am
by GeorG

+- Recent Topics

Size of Image inserted into Forum Topic by scalesusa
February 18, 2017, 07:28:38 pm

Is it possible to not send email notification on sendpm function? by SMFHacks
February 16, 2017, 12:46:02 pm

Create One New Forum Topic with Batch Upload by SMFHacks
February 15, 2017, 09:46:26 pm

Looking for a mod that helps use include image in the post by DenDen60
February 13, 2017, 02:04:07 pm

Issue with resizing of images by SMFHacks
February 12, 2017, 07:30:16 am

Unable to upload MP4 video by landyvlad
February 12, 2017, 07:25:05 am

need help with Trader System 1.7 by snowball
February 11, 2017, 10:18:41 am

In a source file, how do I prompt guests that they are not allowed to enter by shuban
February 10, 2017, 01:35:29 pm

Do not run a query Mysql by GeorG
February 10, 2017, 08:56:57 am

Banned!!! by GeorG
February 10, 2017, 07:55:05 am

Powered by EzPortal