August 18, 2011 at 9:01 am
Hi all,
I'm a newbie so please don't flame if this is a really easy question to the guru's out there.
I have a MySQL table and it has two fields one is populated the other NULL, I want to copy the (value -1) from field A to B. I did write some VB code using a recordset but it was taking forever just wondered if there is a SQL statment that will do it quicker.
P.S. 711,000 records.
thanks
Steve
August 18, 2011 at 9:05 am
This is a SQL Server forum so for detailed help on MySQL you should go to a MySQL Specific forum.
having said that, the SQL syntax to update the one column to the other is:
update YourTable set column1 = column2 - 1
From my limited experience with MySQL i believe that will work correctly. Set based updates are magnitudes faster than doing it from within a recordset, although for 700,000 rows you may want to break it up into smaller batches depending upon what else is going on in your application.
The probability of survival is inversely proportional to the angle of arrival.
August 18, 2011 at 9:09 am
Thanks for the quick reply, I did use the MYSql forum but nobody answered so I came here, sorry for the post but I thought I might get the answer here 🙂 either they are too stuck up on the MYSQL forum or not as good as you guys.
Thanks again
August 18, 2011 at 9:17 am
stephencarr (8/18/2011)
either they are too stuck up on the MYSQL forum or not as good as you guys.Thanks again
Probably both :hehe: We try to help whoever we can, but anything more than generic SQL questions need 2 b specific to SQL Server to get any real response.
Good luck.
The probability of survival is inversely proportional to the angle of arrival.
August 18, 2011 at 9:18 am
Generally speaking, there isn't a site comparable to this one for other database engines.
I've usually found the open-source forums are pretty hit-or-miss on getting help that actually helps, and Oracle resources are usually just "pay me and I'll help you" type scenes. SSC is pretty special and unique, but is limited to MS SQL Server.
On general SQL questions, asking here will usually be okay. Just make sure you mention you need MySQL or ANSI SQL answers. Standard (ANSI) SQL queries should work for either MySQL or MS SQL Server, so we can probably help that way.
Just don't hope for too much when it comes to server administration answers here. Queries, we can probably help with, but admin will be iffy.
And welcome to the forums here. No need to appologize for either the post, the question, or the product used. We're generally a welcoming and friendly bunch. There are exceptions, but that's true of any crowd this size.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
August 18, 2011 at 9:24 am
Try DBForums.com for MySQL questions. It wasn't too bad last time I checked
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
August 18, 2011 at 9:27 am
GSquared (8/18/2011)
Generally speaking, there isn't a site comparable to this one for other database engines.I've usually found the open-source forums are pretty hit-or-miss on getting help that actually helps, and Oracle resources are usually just "pay me and I'll help you" type scenes. SSC is pretty special and unique, but is limited to MS SQL Server.
That's true. I felt it when I had to work on Sybase for a few years. I could hardly find anyone to clarify my doubts other than Sybase tech support.
It is quite easy for SQL Server professionals because of a very helpful community.
M&M
Viewing 7 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply