PostgreSQL table1
id | columnA | columnB
---+---------------------+--------
1 | A 01,A 02,A 03,A 04 | FALSE
2 | A 01,A 02 | FALSE
3 | A 01,A 02,A 03,A 04 | TRUE
4 | A 01,A 02 | TRUE
I used to use below query to find out how many records:
- Query 1:
SELECT *
FROM DB1.table1
WHERE columnA LIKE 'A 04,%'
OR columnA LIKE '%,A 04,%'
OR columnA LIKE '%,A 04'
AND columnB = 'false'
- Query 2:
SELECT *
FROM DB1.table1
WHERE columnA LIKE 'A 02,%'
OR columnA LIKE '%,A 02,%'
OR columnA LIKE '%,A 02'
AND columnB = 'false'
Is there better way to just have one query to find which column has 'A 02' or 'A 04' and 'FALSE'?