4

ok so I have a table that looks something like this...(using pipe symbol to separate columns)

example1 url|0
example2 url|0
example3 url|1
example4 url|1,2
example5 url|1,3,6

What I am trying to do is to select all rows where column 2 does NOT contain a 1.

I cannot use != because if you look all but one of those would return data because the last 2 rows don't equal 1. I tried scouring SQLite documentation for how to go about writing the statement, but I can't find it. This is what I have so far.

select * from table_name where table_column_name[something needed here]'1';
user2929075
  • 61
  • 1
  • 1
  • 3

2 Answers2

6

Give that "1,2,3" et al are strings, you probably need the LIKE keyword.

 select * from table_name where table_column_name NOT LIKE '%1%'
Ann L.
  • 13,760
  • 5
  • 35
  • 66
2

For matching a list item separated by ,, use:

 SELECT * FROM table WHERE `,`||column||`,` NOT LIKE '%,1,%';

this will match entire item (ie, only 1, not 11, ...), whether it is at list beginning, middle or end.

LS_ᴅᴇᴠ
  • 10,823
  • 1
  • 23
  • 46