Wert um 1 erhöhen (UPDATE - SET)

hhbr89

Aktiver Benutzer
Beiträge
34
I am trying to update a field by using this query:

$sql2 = "UPDATE ujc72_rseventspro_events SET discounts = discounts + 1 WHERE id = '$id' ";

But it won´t work. When I use:

$sql2 = "UPDATE ujc72_rseventspro_events SET discounts = 1 WHERE id = '$id' ";

It works like a charm, so there is no problem with the connection etc.

I am using PHP 7 and Joomla 3.5

Anyone an idea?
 
Werbung:
works for me:

Code:
test=# create table bla (i int default 0);
CREATE TABLE
test=*# select * from bla;
 i
---
(0 rows)

test=*# insert into bla values (default);
INSERT 0 1
test=*# insert into bla values (default);
INSERT 0 1
test=*# select * from bla;
 i
---
 0
 0
(2 rows)

test=*# update bla set i = i +1;
UPDATE 2
test=*# select * from bla;
 i
---
 1
 1
(2 rows)

test=*# update bla set i = i +1;
UPDATE 2
test=*# select * from bla;
 i
---
 2
 2
(2 rows)
 
Werbung:
Zurück
Oben