You have a table address and want to check if there’s already a row with address_id = 100 existing.

You can use COUNT to check:

SELECT COUNT(*) FROM address WHERE address_id = 100;

But if you are looking for a faster query with a yes/no answer:

SELECT EXISTS(SELECT 1 FROM address WHERE address_id = 100);

Check if row exists in a table


Need a good GUI tool for PostgreSQL? Check out TablePlus. It’s native, beautiful, and available for free.

Download TablePlus for Mac.

Not on Mac? Download TablePlus for Windows.

On Linux? Download TablePlus for Linux

Need a quick edit on the go? Download TablePlus for iOS.

TablePlus GUI Tool PostgreSQL