Selecting Multiple values from one string in SQL -
hi using oracle 11. requirement select records have 'new york' , 'dallas'. please note order of cities same record can change. following record set should have 2 records (i.e. rec # 3 , 5). please note values coming in city concatenated using wm_concat function
rec# city 1 new york 2 huston 3 new york;dallas 4 los angles 5 los vegas;dallas;san dieago;new york 6 huston;chicago;salt lake city;cleaveland
i wrote on postgres because oracle fiddle wrong should same
select * cities "city" '%new york%' , "city" '%dallas%' the problem if try search 'york' can match partially , find 'new york' can fix this
select * cities "city" '%york%'; -- find `new york` select * cities ';' || "city" || ';' '%;york%;'; -- correct solve as @egor suggest can single like
select * cities ';' || "city" || ';;' || "city" || ';' '%;dallas;%;new york;%' ;
Comments
Post a Comment