LIMIT 1
SELECT locale
FROM t_shops
WHERE id = '123' AND locale = 'not what i have in DB'
UNION ALL
SELECT 'default locale goes here'
LIMIT 1 ; -- t_shops.locale if available, else default
COALESCE + SUBSELECT
SELECT COALESCE(
( SELECT locale
FROM t_shops
WHERE id = '123' AND locale = 'not what i have in DB'
-- LIMIT 1, if required; depends on UNIQUE (locale) or not
),
'default locale goes here' -- 'default'::locale with type possible
);
Response to comment
Actually, I don't know how to reply to your comment, because I don't know what you want to do.
Can you please post the table schema of your product table?
Something like this:
CREATE TABLE product (id SERIAL PRIMARY KEY,
locale TEXT NOT NULL,
other_column INT NOT NULL);
And the describe with normal english words what you want to do.
Maybe you dont even need to LEFT JOIN two times to the same table...