postgresql - Set value in select statement -


i have 2 views , b created other views (cant use rule on update instead). , b have same 3 columns text_1, text_2, count. till sql looks like:

select a.text_1, a.text_2, coalesce(b.count,a.count) count      left join b on a.text_1 b.text_1 , a.text_2 b.text_2; 

but need rule set value of count 0 of records text_1 text_2 in result of select statement above.

i'm using views because use "create or replace..." statement.

using make simpler , cast boolean integer avoids verbose case

select     text_1, text_2,     coalesce(b.count, a.count) * (not text_1 = text_2)::int count           left join     b using (text_1, text_2) 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo