MySQL use a field as variable for the where statement (with like)
First of all, apologies for the title of this question, but i couldn't come up with anything 开发者_开发技巧better. So jumping straight into the code, here's what im trying to do:
SELECT title,
content,
language,
(SELECT t.iso_code FROM t_language_codes t
WHERE lower(t.iso_code_name) like concat('%', language, '%') LIMIT 1) AS languageMapped
FROM t_publications;
I'm attempting to use the language field with the like of the where statement. Since i'm receiving publications with different languages codes and i'm sort of trying to standardize into the iso format... My question is, how do i make the language field work with the like and '% %' statement? being googleing for a while without luck. Any help most appreciated!.
In the subquery, you need to qualify language
with the name of the table: t_publications.language
.
精彩评论