I am curious how this statement updated 3 rows in Postgres. All the other times I ran it, it would update 0 or 1. Is there a way to find out which rows?
bestsales=# update keyword set revenue = random()*10 where id = cast(random()*99999 as int);
UPDATE 3
id
is the primary key.
id | integer | not null default nextval('keyword_id_seq'::regclass)
"keyword_pkey" PRIMARY KEY, btree (id)
I tried to run it as SELECT
:
bestsales=# select * from keyword where id = cast(random()*99999 as int);
id | keyword | seed_id | source | search_count | country | language | volume | cpc | competition | modified_on | google_violation | revenue | bing_violation
-------+---------------------+---------+--------+--------------+---------+----------+--------+------+-------------+-------------+------------------+---------+----------------
6833 | vizio m190mv | | GOOGLE | 0 | | | 70 | 0.38 | 0.90 | | | |
65765 | shiatsu massage mat | | SPYFU | 0 | | | 110 | 0.69 | | | | |
87998 | granary flour | | SPYFU | 0 | | | 40 | 0.04 | | | | |
(3 rows)
And sometimes it would return more than one. How is that possible?
PostgreSQL 9.5.3