Kingkong
Kingkong

Reputation: 73

change the one value in a row mysql query and update a new value

 event = [eid,pid,visibility]
          3    4     4
          2    3     3
  1. if I want to change the visibility value where eid =3. How to write a mysql query for this I want to change it with specific value

  2. is possible to change the eid, and pid at the same time?

  3. if I want to add or subtract value. for example i want -1 for visibility when i update. what is the query for this?

thank you

Upvotes: 2

Views: 96

Answers (1)

Jimmie Johansson
Jimmie Johansson

Reputation: 1962

I am not quite sure what values you want to put in eid and pid, but sure you can update them at the same time.

Answer to question 1:

UPDATE event SET visibility = visibility-1 WHERE eid = 3

Answer to question 2 & 3:

UPDATE event SET eid = 1, pid = 1, visibility = visibility-1 WHERE eid = 3

I hope this can give you a clear answer to what you want to achive :)

Upvotes: 1

Related Questions