Register
FAQ
Calendar
Search
Today's Posts
Rules
Guidelines
SMS enable your application
via Clickatell’s fast, simple and reliable API's, built to integrate with any system.
Click here
to learn more.
Flash Website Builder
- Trendy Site Builder is a Flash Site Building tool that helps users build stunning websites.
Check Out Custom
Custom Logo Design
by LogoBee. Website Design and Free Logo Templates available.
CodingForums.com
>
:: Server side development
>
MySQL
Multiple row updates
User Name
Remember Me?
Password
Before you post, read our:
Rules
&
Posting Guidelines
Thread Tools
Rate Thread
Enjoy an ad free experience by logging in. Not a member yet?
Register
.
09-24-2012, 04:07 PM
PM User
|
#
1
shaunthomson
New Coder
Join Date: May 2012
Posts: 88
Thanks: 51
Thanked 0 Times in 0 Posts
Multiple row updates
Gidday
Just wondering how, using one query, to update a counter column with + 1 in multiple rows when the row ids are supplied.
So:
UPDATE table
SET col=col+1
WHERE id in (1,2,3)
This doesn't work. It does work if the value of col is static. Is it possible, or will I have to create a separate query for each row update?
Thanks for your help.
shaunthomson
View Public Profile
Find More Posts by shaunthomson
09-24-2012, 06:20 PM
PM User
|
#
2
guelphdad
Super Moderator
Join Date: Mar 2006
Location: St. Catharines, Ontario Canada
Posts: 2,629
Thanks: 4
Thanked 147 Times in 138 Posts
what doesn't work about it?
It would increment the value of col by 1 for for each of id=1, id=2 and id=3.
Users who have thanked guelphdad for this post:
shaunthomson
(09-27-2012)
guelphdad
View Public Profile
Visit guelphdad's homepage!
Find More Posts by guelphdad
09-27-2012, 08:07 AM
PM User
|
#
3
shaunthomson
New Coder
Join Date: May 2012
Posts: 88
Thanks: 51
Thanked 0 Times in 0 Posts
That's what I thought too, but it's not working. I going to go back over my code - I think something I've done is screwy.
shaunthomson
View Public Profile
Find More Posts by shaunthomson
09-27-2012, 12:43 PM
PM User
|
#
4
guelphdad
Super Moderator
Join Date: Mar 2006
Location: St. Catharines, Ontario Canada
Posts: 2,629
Thanks: 4
Thanked 147 Times in 138 Posts
So either
a) you haven't shown your actual query you are having trouble with
b) you've introduced a front end application code that we don't know about
Either or it is tougher for us to help you with the larger picture.
Users who have thanked guelphdad for this post:
shaunthomson
(10-02-2012)
guelphdad
View Public Profile
Visit guelphdad's homepage!
Find More Posts by guelphdad
09-27-2012, 04:45 PM
PM User
|
#
5
abduraooft
Supreme Master coder!
Join Date: Mar 2007
Location: N/A
Posts: 14,678
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
Quote:
UPDATE
table
SET col=col+1
WHERE id in (1,2,3)
What's the actual name of that table?
The name
table
is a mysql keyword. You shouldn't name your table by that word.
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --
(Dr. APJ. Abdul Kalam)
101 ways to post unanswerable questions in CF
!
SPREAD - the global community of drilling, completion & subsea professionals
Users who have thanked abduraooft for this post:
shaunthomson
(10-02-2012)
abduraooft
View Public Profile
Find More Posts by abduraooft
10-02-2012, 02:05 AM
PM User
|
#
6
shaunthomson
New Coder
Join Date: May 2012
Posts: 88
Thanks: 51
Thanked 0 Times in 0 Posts
Thanks guys
I had an error elsewhere in my code. Plus, your comments have be taken in.
Cheers
shaunthomson
View Public Profile
Find More Posts by shaunthomson
Bookmarks
del.icio.us
StumbleUpon
Google
Digg
Jump To Top of Thread
«
Previous Thread
|
Next Thread
»
Thread Tools
Show Printable Version
Email this Page
Rate This Thread
Rate This Thread
:
5 : Excellent
4 : Good
3 : Average
2 : Bad
1 : Terrible
Posting Rules
You
may not
post new threads
You
may not
post replies
You
may not
post attachments
You
may not
edit your posts
BB code
is
On
Smilies
are
On
[IMG]
code is
On
HTML code is
Off
Forum Rules
Forum Jump
User Control Panel
Private Messages
Subscriptions
Who's Online
Search Forums
Forums Home
:: Client side development
JavaScript programming
DOM and JSON scripting
Ajax and Design
JavaScript frameworks
Post a JavaScript
HTML & CSS
XML
Flash & ActionScript
Adobe Flex
Graphics and Multimedia discussions
General web building
Site reviews
Building for mobile devices
:: Server side development
Apache configuration
Perl/ CGI
PHP
Post a PHP snippet
MySQL
Other Databases
Ruby & Ruby On Rails
ASP
ASP.NET
Java and JSP
Other server side languages/ issues
ColdFusion
Python
:: Computing & Sciences
Computer Programming
Computer/PC discussions
Geek News and Humour
Web Projects and Services Marketplace
Web Projects
Small projects (quick fixes and changes)
Medium projects (new script, new features, etc)
Large Projects (new web application, complex features etc)
Unknown sized projects (request quote)
Vacant job positions
Looking for work/ for hire
Project collaboration/ partnership
Paid work offers and requests (Now CLOSED)
Career, job, and business ideas or advice
Domains, Sites, and Designs for sale
Domains for sale
Websites for sale
Design templates and graphics for sale
:: Other forums
Forum feedback and announcements
All times are GMT +1. The time now is
09:43 AM
.
Advertisement
Log in to turn off these ads.
Web Hosting UK
|
Dedicated Server Hosting
|
Shareware Junction
|
Software Geek
|
Flash file uploader
|
Cloud Server
|
Web Hosting Australia
Home
-
Contact Us
-
Archives
-
Link to CF
-
Resources
-
Top
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.