0

I'm trying to nest this query, but I am getting the error: invalid input syntax for type boolean: "%malfunction%".

select *
from (
select column_one, column_two
from table
group by column_one, column_two
) as new_table
where column_two like '%false%' or '%malfunction%' or '%accidental%' or '%mistaken%'
order by column_one

Column_two is not boolean but it's identifying it as one. I feel like I'm missing something small, but I can't find it. Help!

3
  • 3
    You must put the column name on each condition: where column_two like '%false%' or column_two like '%malfunction%' or column_two like '%accidental%' or column_two like '%mistaken%' Commented Jun 28, 2017 at 16:56
  • I knew I wasn't thinking correctly. This was exactly what I was missing. Thanks! Commented Jun 28, 2017 at 17:03
  • Glad to help @Dave Commented Jun 28, 2017 at 17:05

2 Answers 2

1

You can use any(array[...]), example:

with test (col) as (
    values
    ('pear'), ('banana'), ('apple')
)

select *
from test
where col like any(array['%ea%', '%ba%']);

  col   
--------
 pear
 banana
(2 rows)
Sign up to request clarification or add additional context in comments.

Comments

0

Correct syntax is something like select col1, col2, from table_name where condition1 OR condition2 OR condition3 ...;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.