1

My table is named users. I have a column named ID and module. Using mySQL syntax how can i say 'get the column id that equals 3 and update the column module to increment from its original number plus 1'

cnotethegr8
  • 7,342
  • 8
  • 68
  • 104

7 Answers7

2
update users set module = module + 1 where id = 3;
Ray Baxter
  • 3,181
  • 23
  • 27
2

Your question isn't super-clear, but is this what you want?!

UPDATE users
SET module = module + 1
WHERE ID = 3;
Andrew Carmichael
  • 3,086
  • 1
  • 22
  • 21
2
UPDATE users
SET module = module + 1
WHERE ID = 3;
a'r
  • 35,921
  • 7
  • 66
  • 67
2
UDPATE users
SET module = module + 1
WERE ID = 3

What is it, homework? :-)

Mathieu Rodic
  • 6,637
  • 2
  • 43
  • 49
1
"UPDATE users SET module = module + 1 WHERE id=3";

That should get you what you want.

iLLin
  • 759
  • 3
  • 7
1

To do it in MySQL:


UPDATE myDB.users
SET module = module + 1
WHERE ID = 3

Do you need to know how to do this with php as well?

MoarCodePlz
  • 5,086
  • 2
  • 25
  • 31
1

Try this:

update `users` set `module` = `module` + 1 where `id` = '3';
Gauthic
  • 91
  • 1
  • 3