rdbms - Mysql search query with join and subqueries -


i have large mysql database connected php platform.

i have few table structure:

table user:

id (int auto increment not null, primary key) name (varchar 200) spoken_lang (varchar 400) /* value of field id of table languages,                               char ';' separator ;*/ 

table languages

id (int auto increment not null, primary key) /* used in prev table */ name (varchar 200) 

is possible make single search query able compare column user.name, , table languages.name?

something this:

select user.name, languages.name lang   user join languages on user.spoken_lang = ......   

i first have recommend normalize table -- shouldn't storing list of results in single column. if possible, consider creating user_language table stores user_id , language_id.

however, can achieve same results using find_in_set , replace:

select u.name, l.name language user u   join languages l on find_in_set(l.id, replace(u.spoken_lang,';',',')) 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -