psql - update only if row exists (IF THEN)

psql - update only if row exists (IF THEN)

I'm looking to run the follow query:

I'm looking to run the follow query:

UPDATE
    creator.contacts
SET
    status = 'accepted'
WHERE
    (
        account_id = $1
        AND
        contact_id = $2
    )
    OR
    (
        account_id = $2
        AND
        contact_id = $1
    )

But only on a certain condition, which I query using the following:

SELECT
    COUNT(*)
FROM
    creator.contacts
WHERE
    account_id = $1
    AND
    status = 'pending'

Is it possible to combine this into one query?

sql mysql database postgresql

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Introduction to Structured Query Language SQL pdf

SQL stands for Structured Query Language. SQL is a scripting language expected to store, control, and inquiry information put away in social databases. The main manifestation of SQL showed up in 1974, when a gathering in IBM built up the principal model of a social database. The primary business social database was discharged by Relational Software later turning out to be Oracle.

Best MySQL DigitalOcean Performance – ScaleGrid vs. DigitalOcean Managed Databases

Compare ScaleGrid MySQL vs. DigitalOcean Managed Databases - See which offers the best MySQL throughput, latency, and pricing on DigitalOcean across workloads.

Introduction to Structured Query Language SQL pdf

SQL stands for Structured Query Language. SQL is a scripting language expected to store, control, and inquiry information put away in social databases. The main manifestation of SQL showed up in 1974, when a gathering in IBM built up the principal model of a social database. The primary business social database was discharged by Relational Software later turning out to be Oracle.

ScaleGrid DigitalOcean Support for MySQL, PostgreSQL and Redis™

ScaleGrid announces support for their fully managed hosting plans on DigitalOcean for MySQL, PostgreSQL and Redis™. See how developers can improve performance. MySQL and PostgreSQL are the top two open source relational databases in the world, and Redis is the top key-value database

How to Migrate SQL Server in an ASP.NET MVC Application to MySQL and PostgreSQL

In this blog, we are going to learn the procedure to migrate a SQL Server database in an ASP.NET MVC application to MySQL and PostgreSQL. All three, Microsoft SQL Server, MySQL and PostgreSQL, are relational database management systems (RDBMS). MSSQL is developed and maintained by Microsoft, whereas