mysql - Search for field contents contained in other records -


i have list table having on 200,000 rows city column. assume contains following data:

rowid    city  1        toronto  2        milton 3        hamilton 4        delhi 5        new delhi  6        markham 

i want find records city contained in row, e.g. milton (row 2) contained in hamilton (row 3) , delhi (row 4) contained in new delhi (row 5). expect following output:

rowid   city   rowid2   city2 2       milton   3      hamilton 4       delhi    5      new delhi 

can single query output looking for? thanks.

assume table name 'cities'. following sql query should work:

select   c2.rowid, c2.city, c1.rowid, c1.city   cities c1 inner join   cities c2     on instr(c1.city,c2.city)     , c1.rowid != c2.rowid 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -