I want to write a single Postgres SQL statement that says look for a user with color X and brightness Y. If that user exists, return all of its row data. If not, create a new row and pass additional information. The two separate statements would do something like this:
Select (color, brightness, size, age) FROM mytable WHERE color = 'X' AND brightness= 'Y';
If that doesn't return anything, then execute this:
INSERT INTO mytable (color, brightness, size, age) VALUES (X, Y, big, old);
Is there a way to combine these into a single query??