mysql - SQL wildcard between two strings -


suppose have 2 tables:

            table1                         table2        id | citya | cityb              id | cities_queue|         1            c                1    , b , d         2     s        f                2    , b , c ,e         3     d        m                3    , m , d , e 

i want return rows of table 2 includes citya , cityb specific order, first citya , after ( somewhere...) comes cityb. because of accepted result must (a , b , c, e). first thought use command find table2 rows include citya, using substr() receive part of cities_queue comes after citya , using like() again cityb. question is: possible use once like() holding string

 (citya) - % - (cityb)           

where % = wildcard find cities_queue include citya , cityb regardless of between them; if so, please provide right syntax. thanks

not sure point if order of elements has important:

http://sqlfiddle.com/#!9/83459/7

select t2.* table2 t2 inner join table1 t1 on t2.cities_queue concat('%',t1.citya,' , ',t1.cityb,'%') 

or

select t2.* table2 t2 inner join table1 t1 on t2.cities_queue concat('%',t1.citya,' % ',t1.cityb,'%') 

Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -