I'm having trouble figuring out how to ask SQLite to return all entries in a table where "column" contains text found in the results of a select statement.
I would like it to work a little like this, if this makes any sense:
select * from table1`
where ("%" || (column) || "%") like in
("%" || (select different_column from table2) || "%")`
Any help would be much appreciated. Please let me know if anyone needs more information.
EDIT: My apologies, I have edited the formatting to be more readable and have added more specifics below. I have also deleted my ridiculously unreadable comments in favor of just editing this question.
table1 (alerts) contains a column called "lookup_info", which stores a string. The string generally looks like this:
---
:account_description: Administrator
:alertable_class: Computer
:alertable_name: exampledotnet
:network_account_type:
:wmi:
:user: exampledomain\administrator
table2 (devices) contains a column called "name", which stores a string. The string generally looks like this:
so-ws-rm101
What I would like to do is return all entries in table1 (alerts) where table1's "lookup_info" column does not contain somewhere within it a computer name stored in table2 (devices) under table2's "name" column.
Basically, there are some alerts that reference computer names that no longer exist. I want those alerts.
Thank you.
EDIT: I have created an fts3 table by the name of alerts_fts that contains the lookup_info column of all entries within the alerts table. I'm trying my search again using full text search this time. This is the query I am using:
select *
from alerts_fts
where alerts_fts.lookup_info match ( select group_concat(name, " OR ")
from Devices
group by "x")
This should make the query look like:
select *
from alerts_fts
where alerts_fts.lookup_info match (cw-ws-example OR so-p2-132-example OR
... OR so-p4-lastexample)
group by "x")
Naturally, this is still not working. The query returns nothing. What am I doing wrong?