Is there any reason why the following queries would return different results?
select count(id)
from mytable
where
status='active'
and ((textfield1 ilike '%needle%') or (textfield2 ilike '%needle%'));
vs
select count(id)
from mytable
where
status='active'
and ((textfield1 || textfield2) ilike '%needle%');
When I'm running these queries, the former is returning 26
and the latter 19
.
What idiotic mistake am I making?
(('aaa' ilike '%ab%') or ('bbb' ilike '%ab%')) == false
and(('aaa' || 'bbb') ilike '%ab%') == true
. Use something like(textfield1 || CHAR(0) || textfield2)
.SELECT textfield1, textfield2
instead ofSELECT count(id)
, you can see which rows differ between the 2 queries.