I have a table:
CREATE TABLE schema.searches ( search_id serial NOT NULL, search_query character varying(255), search_count integer DEFAULT 1, CONSTRAINT pkey_search_id PRIMARY KEY (search_id) ) WITH ( OIDS=FALSE ); I need something like REPLACE INTO from MySQL. I don't know if I have to write my own procedure or something. Basically:
- Check if the row already exists.
- If so, just add 1 to the count.
- If not, insert it into the database.
I can do this in PHP but rather have that be done in PostgreSQL's C engine.