Hi, On Fri, 22 Nov 2019 at 13:18, Hamish Allan <ham...@gmail.com> wrote: > > Hi, > > Is it possible to achieve the effect of combining the LIKE and IN operators? > > So for instance if I have tables: > > CREATE TABLE names (name TEXT); > INSERT INTO names VALUES ('Alexandra'); > INSERT INTO names VALUES ('Rob'); > > CREATE TABLE matches (match TEXT); > INSERT INTO matches VALUES ('Alex'); > INSERT INTO matches VALUES ('Alexander'); > INSERT INTO matches VALUES ('Alexandra'); > INSERT INTO matches VALUES ('Rob'); > INSERT INTO matches VALUES ('Robin'); > INSERT INTO matches VALUES ('Robert'); > > I can query as follows: > > SELECT * FROM names WHERE name IN (SELECT * FROM matches); > > But can I do something more like: > > CREATE TABLE queries (query TEXT); > INSERT INTO queries VALUES ('Alex%*'); > INSERT INTO queries VALUES ('Rob%*'); > > SELECT * FROM table WHERE name LIKE IN (SELECT * FROM queries); > > Thanks, > Hamish
Will a JOIN not do what you want? SELECT table.* from table t JOIN queries q ON t.name LIKE q.query; (after cleaning up query, to 'Alex%' and 'Rob%') Rgds, Simon _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users