Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite select where column does not contain certain data

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';
like image 734
user2929075 Avatar asked Feb 14 '23 17:02

user2929075


1 Answers

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%'
like image 162
Ann L. Avatar answered Feb 17 '23 08:02

Ann L.