Sep 26, 2016

Sqlite - how to search a table with a list of terms from another table

Here is a little example of how brilliant Sqlite is :

sqlite> .schema country
CREATE TABLE country(id integer primary key autoincrement, name text);
sqlite> .schema search
CREATE TABLE search(term text);
sqlite> select * from country ;
id|name
1|France
2|Czech Republic
3|Italy
4|Great Britain
5|Ireland
6|Slovakia
7|Senegal
sqlite> select * from search ;
term
%fr%
%cz%
%ir%
ai
sqlite> select a.name from country a join search b on a.name like "%"||b.term||"%" ;
name
France
Czech Republic
Great Britain
Ireland

NB : the || is used for Sqlite for concatenation

Subscribe to: Posts (Atom)

Popular Posts

  • A little pseudo painting using ArtRage2 - "Spring" is the word !
  • What is it lately, this unexplainable need to change everything that works ? What about this idiom " if it ain't broke, don't ...
  • After I gave a shot at ArtRage2 bundled with the Wacom tablet, I took the other cd that was in the box - and installed .... Photoshop Eleme...
  • Hannah Wagner (better known by her stage name Miss Hannah Minx; born Oct. 1990) is an American vlogger known on Youtube for her Kawaii ...

AltStyle によって変換されたページ (->オリジナル) /