Facebook  Twitter 

SMFHacks.com

+- +-

SMFHacks.com

+- User Information

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

+- Forum Stats

Members
Total Members: 11984
Latest: adm123123
New This Month: 10
New This Week: 5
New Today: 2
Stats
Total Posts: 38104
Total Topics: 6708
Most Online Today: 114
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 114
Total: 114

Author Topic: Complicated MySQL Query  (Read 1105 times)

0 Members and 1 Guest are viewing this topic.

Offline shuban

  • SMF Store Customer
  • Hero Member
  • *****
  • Posts: 595
    • 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: 14120
    • 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: 595
    • 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
2573 Views
Last post January 31, 2008, 05:28:27 pm
by SMFHacks
11 Replies
5039 Views
Last post February 06, 2012, 03:44:53 am
by spikeweb
4 Replies
3002 Views
Last post July 11, 2016, 12:50:54 pm
by shuban
1 Replies
1984 Views
Last post August 17, 2016, 06:12:18 pm
by SMFHacks
12 Replies
1510 Views
Last post February 10, 2017, 08:56:57 am
by GeorG

+- Recent Topics

[Urgent] What happens to CheckGroupExpire if index.php gets hit hard per second by shuban
August 23, 2017, 04:40:16 pm

Purchase Notification Email to Store Admins by SMFHacks
August 22, 2017, 12:21:44 pm

Advance Fake Users and Guests Online by SMFHacks
August 22, 2017, 12:03:40 pm

Won't install in ShelfLife theme. No code matching "Find" code. by ted245
August 11, 2017, 10:12:59 am

Image Linking Codes section missing after install by ted245
August 11, 2017, 08:31:52 am

please i need a programmer who can build this exact forum using smf by horlique
August 07, 2017, 09:03:25 am

Are SMFHack mods compatible with SMF 2.1? by SMFHacks
August 06, 2017, 07:56:38 am

Allow user to customize username and password by SMFHacks
August 04, 2017, 12:22:53 pm

Reset gallery by SMFHacks
August 03, 2017, 11:04:39 am

Members Can't create a Category to upload photos to by SMFHacks
August 02, 2017, 05:07:03 pm

Powered by EzPortal